Skip to content

Instantly share code, notes, and snippets.

@Mirch
Created September 30, 2018 16:29
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 Mirch/07facd9a43f2d84f76eaea30e676e613 to your computer and use it in GitHub Desktop.
Save Mirch/07facd9a43f2d84f76eaea30e676e613 to your computer and use it in GitHub Desktop.
[HttpGet]
public IActionResult Login()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Login(UserRegisterModel model)
{
var exists = _db.Users.SingleOrDefault(u => u.Email.Equals(model.Username));
if (exists != null)
return View();
var user = _db.Users.SingleOrDefault(u => u.UserName == model.Username);
var result = await _signInManager.PasswordSignInAsync(user, model.Password, true, false);
if (result.Succeeded)
{
return RedirectToAction("Index", "Home");
}
return View();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment