Description
Describe the bug
roleManager.RoleExistsAsync("myRole")
always returns null value as if the role doesn't exist even if its there.
🙌 I will be glad to contribute a fix for it and check if there is any other methods do the same thing
This happens because of role name gets normalized twice, first RoleExistsAsync
normalize the parameter value then pass it to FindByNameAsync
where it gets normalized for the second time which leads to a normalized value doesn't exists
aspnetcore/src/Identity/Extensions.Core/src/RoleManager.cs
Lines 229 to 238 in ad5cc24
aspnetcore/src/Identity/Extensions.Core/src/RoleManager.cs
Lines 318 to 327 in ad5cc24
This case was not covered by unit test because of UpperInvariantLookupNormalizer
is being used as normalizer which dose not make any deference if the value gets normalized more than once, but my case I'm using hashing
To Reproduce
await roleManager.CreateAsync(new IdentityRole("myRole"));
IdentityRole role = await roleManager.RoleExistsAsync("myRole");
//role is null
Exceptions (if any)
No Exceptions.
Further technical details
- ASP.NET Core 5.0