Пример #1
0
 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");
 }
Пример #2
0
 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);
 }