Hello,
is it possible to Restrict Login only to specific Role(s)?
how to do this (in the AccountController)?
robert
Hello,
is it possible to Restrict Login only to specific Role(s)?
how to do this (in the AccountController)?
robert
You can modify the Login method in AccountController to check for the required roles.
var roles = await userManager.GetRolesAsync(user);
if (!roles.Contains("Administrator"))
{
return RedirectWithError("User is not an administrator", redirectUrl);
}
Hello,
how to get the user object after successfully logged in (result.Succeeded)
the following code resturns always null...
var user = await userManager.GetUserAsync(User);
robert
The Login method contains this code:
var user = await userManager.FindByNameAsync(userName);