| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using WMS.BZModels.Models.UserCenterManager;
- using WMS.Info;
- using WMS.BZSqlSugar;
- using WMS.Util;
- namespace WMS.BZServices.BLL
- {
- public class BZLoginUserEditPwdBLL : IBLL
- {
- private static Repository<AclUserInfo> _acluserInfoRepository => new Repository<AclUserInfo>();
- public object OutObjData { get; set; }
- public string SuccessMsg { get; set; } = "用户密码修改成功。";
- public LoginUserInfo LoginUser { get; set; }
- public string InJsonData { get; set; }
- public string BLLDesc { get; private set; } = "用户密码过期修改。";
- public void Exec()
- {
- try
- {
- void action()
- {
- LoginUserEditPwdInfo indata = InJsonData.ToObject<LoginUserEditPwdInfo>();
- if (indata == null)
- {
- throw BZSysExCore.ThrowInEmpty();
- }
- if (string.IsNullOrWhiteSpace(indata.TextU))
- {
- throw BZSysExCore.ThrowFailException("用户名为空。");
- }
- if (string.IsNullOrWhiteSpace(indata.TextOP))
- {
- throw BZSysExCore.ThrowFailException("旧密码为空。");
- }
- if (string.IsNullOrWhiteSpace(indata.TextNP))
- {
- throw BZSysExCore.ThrowFailException("新密码为空。");
- }
- if (indata.TextOP == indata.TextNP)
- {
- throw BZSysExCore.ThrowFailException("旧密码与新密码相同,请重新输入。");
- }
- bool tag = ValidUtil.IsPasswordOne(indata.TextNP);
- if (!tag)
- {
- throw BZSysExCore.ThrowFailException("新密码格式不对,需输入6-25位包含特殊字符。");
- }
- //获取数据
- var user=_acluserInfoRepository.Queryable().Where(it => it.Code.ToUpper() == indata.TextU.ToUpper()).First();
- //ACL_USERITEM user = Ctx.Queryable<ACL_USERITEM>().Where(it => it.F_NO.ToUpper() == indata.TextU.ToUpper()).First();
- if (user == null)
- throw BZSysExCore.ThrowFailException("无法找到指定用户");
-
- if (user.IsStop > 0)
- throw BZSysExCore.ThrowFailException("用户已停用!!!");
- //用户密码已过期
- //if (user.F_AUTOSTOPTIME.ToString("yyyy-MM-dd") != DateTime.MaxValue.ToString("yyyy-MM-dd"))
- //{
- // if (user.F_AUTOSTOPTIME < DateTime.Now)
- // throw BZSysExCore.ThrowFailException("用户已过期!!!");
- //}
- //if (user.F_PWDERRQTY >= SysSetCore.GetSysSet().UserPwdErrQty)
- // throw BZSysExCore.ThrowFailException(string.Format("用户密码错误已超过{0}次,已被锁定。", SysSetCore.GetSysSet().UserPwdErrQty));
- ////用户密码已过期
- //if (user.F_EDITPWDTIME != DateTime.MaxValue)
- //{
- // if (user.F_EDITPWDTIME.AddDays(SysSetCore.GetSysSet().UserPwdExpD) < DateTime.Now)
- // throw BZSysExCore.ThrowLoginTimeout();
- //}
- //用户密码错误
- if (user.Pwd != SysSecurityHelp.Aes256Encrypt(indata.TextOP, user.Secretkey))
- {
- int qty = 5 - user.PwdErrQty;
- if (user.PwdErrQty > 0)
- throw new BZSysExCore(ESysExType.PwdError, string.Format("用户密码错误,您还有{0}次", qty > 0 ? qty : 0));
- else
- throw new BZSysExCore(ESysExType.PwdError, "用户密码错误。");
- }
- _acluserInfoRepository.UpdateModelColumns(p => new AclUserInfo
- {
- Pwd = SysSecurityHelp.Aes256Encrypt(indata.TextNP, user.Secretkey),
- EditWho = user.Code,
- EditTime = DateTime.Now,
- PwdEditTime = DateTime.Now,
- PwdErrQty = 0
- }, it => it.Code.ToUpper() == user.Code.ToUpper());
- }
- _acluserInfoRepository.LoginUseTran(action);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- }
- }
|