Beispiel #1
0
 public ActionResult Login(User user)
 {
     var loginUser = _userService.Login(user);
     if (loginUser != null)
     {
         //var ticket = new FormsAuthenticationTicket(1, user.NickName, DateTime.Now, DateTime.Now.AddMinutes(30),
         //false, "none", FormsAuthentication.FormsCookiePath);
         //string encTicket = FormsAuthentication.Encrypt(ticket);
         //Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
         FormsAuthentication.SetAuthCookie(loginUser.NickName, true);
     }
     return RedirectToAction("Index", "Admin");
 }
Beispiel #2
0
 public User Login(User user)
 {
     user.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(user.Password,
         "MD5");
     return _db.User.FirstOrDefault(t => t.Account == user.Account && t.Password == user.Password);
 }