public async Task <IActionResult> Login(string returnUrl, LoginViewModel model) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Profile")); } if (ModelState.IsValid) { UserModel user = await ManageUser.FindByEmailAsync(model.Email); if (user != null && await ManageUser.CheckPasswordAsync(user, model.Password)) { if (await ManageUser.IsEmailConfirmedAsync(user)) { var result = await SignManager.PasswordSignInAsync(user, model.Password, true, false); if (result.Succeeded) { if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl)) { return(LocalRedirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("Error", result.ToString()); } } else { ModelState.AddModelError("Error", "Email is not verified."); } } else { ModelState.AddModelError("Error", "Failed : Invalid Login Attempt"); } } return(View(model)); }
// GET: Account/ConfirmEmail?token=value&email=value public async Task <IActionResult> ConfirmEmail(string token, string email) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Profile")); } UserModel user = await ManageUser.FindByEmailAsync(email); if (user != null && !await ManageUser.IsEmailConfirmedAsync(user)) { var result = await ManageUser.ConfirmEmailAsync(user, token); if (result.Succeeded) { return(RedirectToAction("Login")); } } return(View("Verify")); }