public ActionResult Login(RegisterModel user) { // check if user exists var checkUser = _accountService.Login(user); if (checkUser == null) { return(View()); } // rest JavaScriptSerializer jsData = new JavaScriptSerializer(); UserCookie userCookie = new UserCookie(checkUser); string data = jsData.Serialize(userCookie); FormsAuthenticationTicket autho = new FormsAuthenticationTicket(1, checkUser.Id.ToString(), DateTime.Now, DateTime.Now.AddMonths(6), true, data); string encToken = FormsAuthentication.Encrypt(autho); HttpCookie authoCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encToken); Response.Cookies.Add(authoCookie); return(RedirectToAction("Index", "Home")); }
public UserIdentity(UserCookie user) { Identity = new GenericIdentity(User.Id.ToString()); User = user; }