Reputation: 643
I am using the identity model that comes standard with the MVC template.
I can find the role the user is in using user.Roles which gives me a list of IdentityUserRole. But I only have access to the RoleId.
I basically what to check if the user is in the "Admin" role.
Upvotes: 1
Views: 1131
Reputation: 166
You can use UserManager
to check if an application user has some role. Try
bool result = _userManager.IsInRole("userId", "Admin");
Or
bool result = await _userManager.IsInRoleAsync("userId", "Admin");
Upvotes: 0
Reputation: 471
You can also use Enums for this purpose for more details regarding visit More Help regarding Enum
Upvotes: -1