Exemplo n.º 1
0
        public IActionResult TherapistUpdatePassword(string password)
        {
            // 前端传输的密码为MD5加密后的结果
            if (string.IsNullOrEmpty(password) || password.Length != 32)
            {
                return(Failed(ErrorCode.FormatError, "密码为空或者无效"));
            }
            var therapistBiz = new TherapistBiz();
            var biz          = new AccountBiz();
            var userModel    = therapistBiz.GetAsync(UserID).Result;

            if (userModel == null)
            {
                return(Failed(ErrorCode.Empty, "用户不存在或者已经注销"));
            }

            userModel.TherapistPassword = CryptoHelper.AddSalt(UserID, password);
            if (string.IsNullOrEmpty(userModel.TherapistPassword))
            {
                return(Failed(ErrorCode.SystemException, "密码加盐失败"));
            }

            return(therapistBiz.UpdateAsync(userModel).Result ? Success() : Failed(ErrorCode.DataBaseError, "密码更新失败"));
        }