public ActionResult UserLogin(Login model) { var vLogin = _userServices.Login(model.Name, model.Password); if (vLogin.IsLogin) { SetRemember(model); var client = Client.GetAddress(); _userServices.AddLogin(vLogin, client.Ipv4); vLogin.User.Updatetime = DateTime.UtcNow; var identityModel = new IdentityModel <User>() { LoginTime = DateTime.UtcNow, Model = vLogin.User }; BaseIdentity.SetIdentity <User>(vLogin.SessionId, identityModel); model.SessionId = vLogin.SessionId; model.IsLogin = true; } if (vLogin.LoginStats == LoginStats.NAME) { ViewBag.Message = "邮箱或手机号错误."; model.IsLogin = false; } else if (vLogin.LoginStats == LoginStats.PASSOWRD) { ViewBag.Message = "密码错误."; model.IsLogin = false; } return(View("Index", model)); }
private void SetRemember(Login model) { var isRememberMe = Request.Form["RememberMe"]; if (model.RememberMe == 1) { Client.SetCookie(REMEMBER, model.SerializeObject()); } }