public ActionResult LogIn(AccountLogInModel model) { if (User == null) { if (!ModelState.IsValid) return View(model); if (!AuthenticationService.ValidateUser(model.EmailAddress, HashString(model.Password))) { DisplayError("Sorry, invalid username and/or password. Please try again."); return View(model); } SetAuthCookie(model); if (!string.IsNullOrEmpty(model.ReturnUrl)) return Redirect(model.ReturnUrl); } return RedirectToAction("Index", "Home"); }
private void SetAuthCookie(AccountLogInModel model) { var ticket = GetFormsAuthenticationTicket(model.EmailAddress, model.RememberMe); var encryptedTicket = FormsAuthentication.Encrypt(ticket); var authCookie = new HttpCookie( FormsAuthentication.FormsCookieName, encryptedTicket) { Secure = true }; Response.SetCookie(authCookie); }