public ActionResult RegisterUser(BaseUser userInfo) { if (string.IsNullOrEmpty(userInfo.UserName) || string.IsNullOrEmpty(userInfo.PassWord)) { return Content("用户名或密码不能为空!"); } userInfo.Code = Guid.NewGuid().ToString(); //随机产生的一些数据 userInfo.QuickQuery = userInfo.UserName; userInfo.UserFrom = "用户注册"; _userInfoService.AddEntity(userInfo); return Content("OK"); }
public ActionResult CheckUserInfo(BaseUser userInfo, string code) { //var sessionCode = this.TempData["ValidateCode"] == null // ? new Guid().ToString() // : this.TempData["ValidateCode"].ToString(); ////将验证码去掉,避免暴力破解 //this.TempData["ValidateCode"] = new Guid(); ////判断用户输入的验证码是否正确 //if (sessionCode != code) //{ // return Content("验证码输入不正确"); //} //调用业务逻辑层(BLL)去校验用户是否正确 var loginUserInfo = _baseUserService.CheckUserInfo(userInfo); if (loginUserInfo == LoginResult.Success) { string enStr = CookiesHelper.Encrypt(userInfo.ID.ToString(), CookiesHelper.CookiesKey); CookiesHelper.SaveCookies(ProjectConst.CookiesClient, ProjectConst.CookiesClientID, enStr, DateTime.Now.AddHours(12)); } //获得错误信息(枚举的Description) var userInfoError = EnumManager<LoginResult>.GetDescriptionByName(loginUserInfo); return Content(userInfoError); }