Beispiel #1
0
        public bool ResetPassword(RequestChangePasswordDTO dto)
        {
            using (var db = new DBEntities())
            {
                var password = StringEncrypt.EncryptWithMD5(dto.NewPassword);
                var model    = db.Users.Where(t => t.ID == dto.ID && !t.IsDeleted).FirstOrDefault();

                if (model != null)
                {
                    model.Password = password;
                    var ret = db.SaveChanges() > 0;

                    return(ret);
                }
                return(false);
            }
        }
Beispiel #2
0
        public ApiResult ResetPassword([FromBody] RequestChangePasswordDTO request)
        {
            var ret = userService.ResetPassword(request);

            if (ret)
            {
                return(new ApiResult()
                {
                    Status = EnumApiStatus.BizOK, Msg = "操作成功"
                });
            }
            else
            {
                return(new ApiResult()
                {
                    Status = EnumApiStatus.BizError, Msg = "修改失败"
                });
            }
        }
Beispiel #3
0
        public ApiResult UpdatePassword([FromBody] RequestChangePasswordDTO request)
        {
            request.ID = SecurityHelper.LoginUser.ID;
            var ret = userService.UpdatePassword(request);

            if (ret)
            {
                return(new ApiResult()
                {
                    Status = EnumApiStatus.BizOK, Msg = "操作成功"
                });
            }
            else
            {
                return(new ApiResult()
                {
                    Status = EnumApiStatus.BizError, Msg = "旧密码错误"
                });
            }
        }