Ejemplo n.º 1
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="requestModel"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public BusinessBaseViewModel <string> UpdatePwd(UpdatePwdSystemStaffRequestModel requestModel, int id)
        {
            var res = new BusinessBaseViewModel <string>()
            {
                Status = ResponseStatus.Fail
            };

            if (requestModel == null)
            {
                res.ErrorMessage = "参数错误";
                return(res);
            }
            if (requestModel.OldLoginPwd.IsNullOrWhiteSpace())
            {
                res.ErrorMessage = "旧密码不能为空";
                return(res);
            }
            if (requestModel.NewLoginPwd.IsNullOrWhiteSpace())
            {
                res.ErrorMessage = "新密码不能为空";
                return(res);
            }
            var staffEntity = _staffRepostory.FirstOrDefault(x => x.Id == id);

            if (staffEntity != null)
            {
                if (staffEntity.LoginPwd.Equals((requestModel.OldLoginPwd + staffEntity.MaskCode).ToMd5(), StringComparison.InvariantCultureIgnoreCase))
                {
                    staffEntity.LoginPwd = (requestModel.NewLoginPwd + staffEntity.MaskCode).ToMd5();

                    _staffRepostory.Update(staffEntity, "LoginPwd");
                    _staffRepostory.SaveChanges();
                    res.Status = ResponseStatus.Success;
                }
                else
                {
                    res.ErrorMessage = "旧密码错误";
                    return(res);
                }
            }

            return(res);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public ActionResult UpdatePwd(UpdatePwdSystemStaffRequestModel requestModel)
        {
            var ret = _systemStaffService.UpdatePwd(requestModel, base.GetLoginUserInfo.Id);

            return(Content(ret.ToJsonString()));
        }