public H5ResponseViewModel <Object> Register([FromBody] H5RequestViewModel Parameters) { var sysCode = _sys.CheckParameters(Parameters.data, "Register"); H5ResponseViewModel <Object> response = null; string phone = Parameters.data.phone; string strKey = $"{CacheKey.Rgister.ToString()}{phone}"; if (sysCode == SysCode.Ok) { if (RedisHelper.KeyExists(strKey, RedisFolderEnum.code, RedisEnum.Four) && RedisHelper.StringGet(strKey, RedisFolderEnum.code, RedisEnum.Four).Equals((string)Parameters.data.verifyCode)) { var salt = _sys.GetRandomSeed(8); long userId = _user.Register(new RegisterDto { App_version = "", Channel = Parameters.data.channelId, Createtime = DateTime.Now, Device_code = "", Os_type = "", Gps = "", Os_version = "", Phone = phone, Platform = "H5", Updatetime = DateTime.Now }, new UserLoginDto { Createtime = TimeHelper.GetDateTime(), Is_first = 1, Password = _sys.Md5Encode($"{(string)Parameters.data.password}{salt}"), Phone = phone, Status = 0, Salt = salt, Updatetime = TimeHelper.GetDateTime(), }, new UserInfoDto { Createtime = TimeHelper.GetDateTime(), Head = "", Updatetime = TimeHelper.GetDateTime(), Nick_name = "" }); if (userId != 0) { RedisHelper.KeyDelete(strKey, RedisFolderEnum.code, RedisEnum.Four); } else { sysCode = SysCode.Err; } } else { sysCode = SysCode.CodeErr; } } response = new H5ResponseViewModel <Object>(sysCode, null); return(response); }
public async Task <H5ResponseViewModel <object> > UpdatePwd([FromBody] H5RequestViewModel Parameters) { H5ResponseViewModel <object> response = null; var sysCode = _sys.CheckParameters(Parameters.data, "UpdatePwd_H5"); string token = Parameters.data.token; bool isLog = _token.VerifyToken(token); if (sysCode == SysCode.Ok) { if (isLog) { var userLogin = JsonHelper.DeserializeJsonToObject <UserLoginDto> (RedisHelper.StringGet($"{CacheKey.Token}{token}", RedisFolderEnum.token, RedisEnum.Five)); var salt = _sys.GetRandomSeed(8); string pwd = _sys.Md5Encode($"{(string)Parameters.data.password}{salt}"); string pwdEctype = _sys.Md5Encode($"{(string)Parameters.data.passwordEctype}{salt}"); if (pwd.Equals(pwdEctype)) { string verifyCode = Parameters.data.verifyCode; string strKey = $"{ CacheKey.UpdatePwd.ToString()}{userLogin.Phone}"; if (RedisHelper.KeyExists(strKey, RedisFolderEnum.code, RedisEnum.Four) && RedisHelper.StringGet(strKey, RedisFolderEnum.code, RedisEnum.Four).Equals(verifyCode)) { if (userLogin.Password.Equals(pwd)) { sysCode = SysCode.PwdNoDifference; //密码一致 } else { if (!await _user.UpdatePwdAsync(userLogin.Userid, pwd, salt)) //修改密码 { sysCode = SysCode.Err; } RedisHelper.KeyDelete(strKey, RedisFolderEnum.code, RedisEnum.Four); //删除验证码缓存 } } else { sysCode = SysCode.CodeErr; } } else { sysCode = SysCode.PwdInconformity; } } else { sysCode = SysCode.TokenLose; } } response = new H5ResponseViewModel <object>(sysCode, null); return(response); }
public ResponseViewModel <UserTokenView> register([FromBody] RequestViewModel obj) { UserTokenView token = new UserTokenView(); ResponseViewModel <UserTokenView> response = null; obj = JsonHelper.DeserializeJsonToObject <RequestViewModel>(Content(User.Identity.Name).Content); string strKey = $"{CacheKey.Rgister.ToString()}{obj.Data.phone}"; if (RedisHelper.KeyExists(strKey, RedisFolderEnum.code, RedisEnum.Four) && RedisHelper.StringGet(strKey, RedisFolderEnum.code, RedisEnum.Four).Equals((string)obj.Data.verifyCode)) { var salt = _sys.GetRandomSeed(8); long userId = _user.Register(new RegisterDto { App_version = obj.Client.Version, Channel = obj.Client.Channel, Createtime = DateTime.Now, Device_code = obj.Client.DeviceCode, Os_type = obj.Client.OsType, Gps = obj.Client.Gps, Os_version = obj.Client.OsVersion, Phone = obj.Data.phone, Platform = obj.Client.Platform, Updatetime = DateTime.Now }, new UserLoginDto { Createtime = TimeHelper.GetDateTime(), Is_first = 1, Password = _sys.Md5Encode($"{(string)obj.Data.password}{salt}"), Phone = obj.Data.phone, Status = 0, Updatetime = TimeHelper.GetDateTime(), Salt = salt }, new UserInfoDto { Createtime = TimeHelper.GetDateTime(), //Head = "", Updatetime = TimeHelper.GetDateTime(), //Nick_name = "" }); if (userId != 0) { //获取token token = _token.GetToken(userId); response = new ResponseViewModel <UserTokenView>(SysCode.Ok, token, obj.Encrypt, _sys, obj.Secret); _user.RecordLoginLogAsync(new userLoginLogDto { App_version = obj.Client.Version, Createtime = TimeHelper.GetDateTime(), Device_code = obj.Client.DeviceCode, Gps = obj.Client.Gps, Os_type = obj.Client.OsType, Os_version = obj.Client.OsVersion, Phone = obj.Data.phone, Userid = userId }); RedisHelper.KeyDelete(strKey, RedisFolderEnum.code, RedisEnum.Four); } else { response = new ResponseViewModel <UserTokenView>(SysCode.Err, null, obj.Encrypt, _sys, obj.Secret); } } else { /*不存在验证码,返回验证码错误*/ response = new ResponseViewModel <UserTokenView>(SysCode.CodeErr, null, obj.Encrypt, _sys, obj.Secret); } return(response); }