[AllowAnonymous] | |
public async Task<IActionResult> Login(string username, string password) | |
{ | |
if (IsValidUser(username, password)) | |
{ | |
var claims = new List<Claim>(2); | |
claims.Add(new Claim(ClaimTypes.Name, username)); | |
claims.Add(new Claim(ClaimTypes.Role, "GroupThatUserIsIn", | |
ClaimValueTypes.String, "IHaveIssuedThis")); | |
await HttpContext.SignInAsync( | |
CookieAuthenticationDefaults.AuthenticationScheme, | |
new ClaimsPrincipal(new ClaimsIdentity(claims, | |
CookieAuthenticationDefaults.AuthenticationScheme))); | |
return RedirectToAction("Index"); | |
} | |
return View(); | |
} | |
private bool IsValidUser(string username, string password) | |
{ | |
return username == "foo" && password == "bar"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment