Hi Guys,
I have an query, basically we have requirement before sign-in check for whether user is active subscriber or not, if he try for 3 times it should lockout.
In below code it's locking out the user if he try's to attempt 3 times but how to check for active subscriber Lockout. Below is code
// POST: /Account/Login [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return View(model); } //Should we put active subscriber check at this line ? // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout : true); HttpCookie rmCookie = new HttpCookie("RM"); rmCookie.Value = model.RememberMe.ToString(); Request.Cookies.Add(rmCookie); Response.Cookies.Add(rmCookie); switch (result) { case SignInStatus.Success: { //Update LastLogin date to aspnetuser table var user = await UserManager.FindAsync(model.UserName, model.Password); user.LastLoginDate = DateTime.Now; UserManager.Update(user); } 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(model); } }
Many thanks
Shabbir