Skip to content

Instantly share code, notes, and snippets.

@alistairjevans
Last active September 7, 2019 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alistairjevans/65d27bcff1788a6c92cad37dc9311a6b to your computer and use it in GitHub Desktop.
Save alistairjevans/65d27bcff1788a6c92cad37dc9311a6b to your computer and use it in GitHub Desktop.
Added SignMeIn
public async Task<IActionResult> SignMeIn()
{
// Just do a real basic login.
var claims = new List<Claim>
{
new Claim(ClaimTypes.Name, "ajevans"),
new Claim("FullName", "Alistair Evans"),
new Claim(ClaimTypes.Role, "Administrator"),
};
var claimsIdentity = new ClaimsIdentity(claims, "AuthCookie");
await HttpContext.SignInAsync(
"AuthCookie",
new ClaimsPrincipal(claimsIdentity));
Logger.LogInformation("Signed in {user}", claimsIdentity.Name);
return RedirectToAction(nameof(Index));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment