-
-
Save mclasson/ccce84b5dabcfc437dd3164820679430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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