Member Username cannot be same as a member's id #17097
Labels
affected/v13
area/backend
state/reproduced
state/sprint-candidate
We're trying to get this in a sprint at HQ in the next few weeks
type/bug
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
13.4.0
Bug summary
The member username cannot be the same as the member id if the member is in the cache.
If the username is the id of another member and that member is cached, MemberService.GetByUsername will return the wrong member.
When trying to get the member using MemberService.GetByUsername, do not check the id, only the username.
Specifics
In the MemberRepository.cs where the username cache is created, it writes the same CacheKey as for the normal entity cache.
I guess this should be fixed.
Username Cache:
Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs
Lines 230 to 231 in 00ca9e0
Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs
Lines 69 to 70 in 00ca9e0
Entity Cache:
Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepositoryBase.cs
Lines 196 to 197 in 00ca9e0
Cache Key:
Umbraco-CMS/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs
Lines 231 to 246 in c8899af
Umbraco-CMS/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs
Line 31 in c8899af
Steps to reproduce
Create a member and give them a random number (12345) as their username:
Check the new member's id and copy it (1499):
Now create another member with the copied id (1499) as their username. Click save and you will see that the username is already taken:
Once the cache is cleared (after 5 minutes or a reboot), a member can be created with the username of the first member created ID (1499) without the validation error:
When the cache is cleared (after 5 minutes or a reboot), save the first member (Test Member 12345) and try to get the new member by username (1499).
You will get the first member (Test Member 12345) instead of the correct member (Test Member 1499):
@using Umbraco.Cms.Core.Services @inject IMemberService memberService @{ var member = memberService.GetByUsername("1499"); if (member != null) { <p> Member: @member.Name </p> } }
OUTPUT: Member: Test Member 12345
EXPECTED OUTPUT: Member: Test Member 1499
Expected result / actual result
When reproducing you should see the error and the wrong cache.
The expected result would be to allow any username for a member, even if it is another member's id and to have the correct member returned.
This item has been added to our backlog AB#45490
The text was updated successfully, but these errors were encountered: