public ActionResult Details(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } LoginVm user = new LoginVm { EmailLog = "a@a" }; if (user == null) { return HttpNotFound(); } return View(user); }
public async Task<ActionResult> Login( LoginVm Model, string ReturnUrl) { if (!ModelState.IsValid) { return View(Model); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var user = await UserManager.FindAsync(Model.EmailLog, Model.Password); if (user != null) { if (user.EmailConfirmed == true) { var result = await SignInManager.PasswordSignInAsync(Model.EmailLog, Model.Password, Model.RememberMe, shouldLockout: true); switch (result) { case SignInStatus.Success: return RedirectToLocal(ReturnUrl); case SignInStatus.LockedOut: return View("Lockout"); case SignInStatus.RequiresVerification: // return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); // return View("Welcome", badModel); break; } } else { ModelState.AddModelError("", "Account is not confirmed. Учётная запись не подтверждена"); } } else { ModelState.AddModelError("", "Account not found. Учётная запись не найдена"); } Tuple<RegisterVm, LoginVm> badModel = new Tuple<RegisterVm, LoginVm>(new RegisterVm(), Model); return View("Welcome", badModel); }