public ActionResult LogonWidget() { UserLogin user; if (CurrentUserLogin == null) { user = new UserLogin() { IsActive = true, IsLoggedIn = false, FailureCount = 0 }; } else { user = CurrentUserLogin; } return View(user); }
public ActionResult Login(UserLogin userLogin) { if (userLogin == null) { return RedirectToAction("Index", "Home"); } User user = Repository.GetUser(userLogin.Username); if (user != null) { // TODO : Check password // Save user's credentials userLogin.IsLoggedIn = true; userLogin.UserId = user.UserId; CurrentUserLogin = userLogin; RedirectToRouteResult result = RedirectToAction("Index", "Home"); return new LoginActionResult(result); } userLogin.Username = ""; userLogin.Password = ""; userLogin.FailureCount++; if (userLogin.FailureCount >= 3) { userLogin.IsActive = false; } CurrentUserLogin = userLogin; return RedirectToAction("Index", "Home"); }