Skip to content

Instantly share code, notes, and snippets.

@explorer14
Created May 3, 2018 19:07
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 explorer14/f24a69b5402dd8f74a334cf49733c9a4 to your computer and use it in GitHub Desktop.
Save explorer14/f24a69b5402dd8f74a334cf49733c9a4 to your computer and use it in GitHub Desktop.
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task Login(UserCredentials userCredentials,
string returnUrl = null)
{
ViewBag.returnUrl = returnUrl;
var returnTo = "/Account/Login";
// Replace this with your custom authentication logic
if (userCredentials.Username == "user1" &&
userCredentials.Password == "pass1")
{
var userInfo = new UserInfo
{
FirstName = "UserFName",
LastName = "UserLName"
};
var accessTokenResult =
tokenGenerator.GenerateAccessTokenWithClaimsPrincipal(
userCredentials.Username,
AddMyClaims(userInfo));
await HttpContext.SignInAsync(accessTokenResult.ClaimsPrincipal,
accessTokenResult.AuthProperties);
returnTo = returnUrl;
}
return RedirectToLocal(returnTo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment