public ActionResult LogIn(LogIn login) { if (ModelState.IsValid) { var log = AutoMapper.Mapper.Map <Models.LogIn, Account>(login); Account account = UserRespo.LogIn(log); if (account != null) { FormsAuthentication.SetAuthCookie(account.MailID, false); var authTicket = new FormsAuthenticationTicket(1, account.MailID, DateTime.Now, DateTime.Now.AddMinutes(20), false, account.Role); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); HttpContext.Response.Cookies.Add(authCookie); } } return(View()); }
public static Account LogIn(Account account) { return(UserRespo.LogIn(account)); }