public async Task <ActionResult> Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { AuthorizedPerson user = await UserManager.FindAsync(model.Email, model.Password); if (user == null) { ModelState.AddModelError("", "Wrong login or password."); } else { ClaimsIdentity claim = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignOut(); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, claim); if (String.IsNullOrEmpty(returnUrl)) { return(RedirectToAction("Index", "Home")); } return(Redirect(returnUrl)); } } ViewBag.returnUrl = returnUrl; return(View(model)); }
public async Task <ActionResult> DeleteConfirm() { AuthorizedPerson user = await UserManager.FindByEmailAsync(User.Identity.Name); if (user != null) { IdentityResult result = await UserManager.DeleteAsync(user); if (result.Succeeded) { return(RedirectToAction("LogOff", "Account")); } } return(RedirectToAction("Index", "Home")); }