Пример #1
0
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="newPsw">新密码</param>
        /// <param name="validateCode">验证码</param>
        /// <returns></returns>
        public async Task <OperationResult> ResetPassword(string userName, string newPsw, string validateCode)
        {
            userName.CheckNotNullOrEmpty("userName");
            newPsw.CheckNotNullOrEmpty("newPsw");
            validateCode.CheckNotNullOrEmpty("validateCode");

            //验证码
            var severCode = GetValidateCode(userName, CodeType.找回密码);

            if (severCode == null || severCode.Code != validateCode)
            {
                return(await Task.FromResult(new OperationResult(OperationResultType.ValidError, "验证码错误")));
            }

            var sUser = await UserManager.FindByNameAsync(userName);

            if (sUser == null)
            {
                return(new OperationResult(OperationResultType.NoChanged, "用户不存在"));
            }

            if (sUser.UserType != UserType.App用户)
            {
                return(new OperationResult(OperationResultType.NoChanged, "用户不存在"));
            }

            sUser.PasswordHash = UserManager.PasswordHasher.HashPassword(newPsw);

            var result = SysUserRepo.Update(sUser);

            return(result == 0 ? new OperationResult(OperationResultType.ValidError, "服务器繁忙") : new OperationResult(OperationResultType.Success, "密码重置成功"));
            //UserInfoRepo.Update(sUser);
            //UserManager.RemovePassword(sUser.Id);
            //UserManager.AddPassword(sUser.Id, newPsw);
        }
Пример #2
0
 /// <summary>
 /// 用model更新用户信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateUserInfo(SysUser model)
 {
     return(SysUserRepo.Update(model));
 }