public ActionResult SignIn(SignInViewModel model) { if (ModelState.IsValid) { // Attempt to authenticate. AuthenticationResult result = _accountService.Authenticate(model.Email, model.Password); // Write cookie to save email. HttpCookie emailCookie = new HttpCookie(EMAIL_COOKIE_NAME, model.Email); emailCookie.Expires = DateTime.Today.AddMonths(1); Response.Cookies.Add(emailCookie); // Success. if (result.Status == AuthenticationStatus.Success) { FormsAuthentication.SetAuthCookie(model.Email, false); UpdateCurrentTheme(model.Email); return JsonRedirect(Url.Action("index", "home")); } // Pending change password. if (result.Status == AuthenticationStatus.PendingChangePassword) { FormsAuthentication.SetAuthCookie(model.Email, false); UpdateCurrentTheme(model.Email); return JsonRedirect(Url.Action("changepassword", "signin")); } // Authentication failed. model.Message = result.Message; } // Return content. return JsonContent("#sign-in-form-panel", RenderPartialViewToString("_SignInForm", model)); }
public ActionResult SignIn() { SignInViewModel model = new SignInViewModel(); if (Request.Cookies[EMAIL_COOKIE_NAME] != null) { model.Email = Server.HtmlEncode(Request.Cookies[EMAIL_COOKIE_NAME].Value); } if (Request.IsAjaxRequest()) return PartialView("_SignInForm", model); else return View(model); }