We're using ASP.Net ZERO Core MVC 11.3.
We have been using IsInRoleAsync without issue, until we needed to return a Role that isn't one of the defaults ie Admin or User.
We were looking for the role "Manager", but we noticed it wasn't working, so we checked and found it is returning the value "97d5491d35b440edbb5fc33169f91d1b" instead of "Manager".
Somehow, new roles that are added to the database have "GUID-like" values in the Name and NormalizedName fields such as 97d5491d35b440edbb5fc33169f91d1b and 97D5491D35B440EDBB5FC33169F91D1B.
However, Admin and User have Admin and ADMIN and User and USER as expected in the Name and NormalizedName fields.
Any ideas why this is happening to newly created Roles? Is it by design? If not, was this fixed in a later version?
3 Answer(s)
-
0
Hi @Mitch
Yes, this is by design. It is set here https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Zero.Common/Authorization/Roles/AbpRoleBase.cs#L66
-
0
Thanks for confirming.
So how do I find out what Roles the current user has assigned if IsInRoleAsync returns a random GUID value? It only seems to work for Admin and User as they don't use GUID's for the name.
I want to check for the Role "Manager" in the Current User
-
0
Hi @Mitch
If you manually need to check the role, you can get the role by its display name and then use its Name field. Could you explain your scenario ? Maybe this will not be necessary at all.