Commit deaaeb97 authored by 李纪文's avatar 李纪文

feat: 密码前端正则校验

parent 77b8a7ad
Pipeline #94757 waiting for manual action with stages
......@@ -101,6 +101,10 @@ const appReducer = (state = initialState, action) => {
? action.data.VerificationConfig?.VerificationCodeType || ''
: '';
// temp.isVerificationCode 为false 时,不能用短信验证码
// 密码校验
temp.PasswordAuth = action.data.PasswordAuth || '否';
temp.PasswordRule = action.data.PasswordRule || '';
temp.PasswordTip = action.data.PasswordTip || '';
window.globalConfig = temp;
// eslint-disable-next-line no-undef
......
......@@ -1550,8 +1550,25 @@ class Login {
}
}
passwordAuthVerify(pwd) {
const self = this;
let authTitle = null;
try {
if (self?.globalConfig?.PasswordAuth === '是' && self?.globalConfig?.PasswordRule) {
const reg = new RegExp(self.globalConfig.PasswordRule);
const passwordTip = self?.globalConfig?.PasswordTip || '您的密码不符合规则,请重新输入';
authTitle = reg.test(pwd) ? null : passwordTip;
}
} catch (err) { };
if (authTitle) {
message.error(authTitle);
throw `密码:${authTitle}`;
}
}
loginHandler(user, pwd, userPhone, isRememberPWD, ref) {
const self = this;
self.passwordAuthVerify(pwd);
if (user && pwd) {
if (self.loginFailed && self.captchaObj) {
self.captchaObj.verify();
......@@ -1567,6 +1584,7 @@ class Login {
loginHandlerValidate(user, pwd, userPhone, isRememberPWD, ref, validateCode = '') {
const self = this;
self.passwordAuthVerify(pwd);
// isVerification 取自系统配置表,isVerificationCode 取自 站点配置,isVerificationCode为1 会默认把 isVerificationCode改为true
if ((this.globalConfig?.isVerification || 0) * 1 === 1 || this.globalConfig.isVerificationCode)
return self.loginValidate(user, pwd, userPhone, isRememberPWD, SERVICE_APP_LOGIN_MODE.password, validateCode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment