Commit 8136c1ce authored by 皮倩雯's avatar 皮倩雯

fix: '用户密码自定义验证规则'

parent 306bad43
Pipeline #76531 passed with stages
import React, { useEffect, useState } from 'react';
import { Modal, Form, Input, notification, message, TreeSelect, Select } from 'antd';
import { addUser, GetUserRelationListNew } from '@/services/userManage/api';
import {
addUser,
GetUserRelationListNew,
GetPasswordRegularization,
} from '@/services/userManage/api';
import classNames from 'classnames';
import sha1 from 'sha1';
import { ok } from '../../../assets/images/icons/ok.svg';
......@@ -19,6 +23,7 @@ const AddUserModal = props => {
const [value, setValue] = useState(['0-1-1']);
const [treeData, setTreeData] = useState([]);
const [passwordLevel, setPasswordLevel] = useState(''); // 密码等级
const [rules, setRules] = useState();
const onChange = newValue => {
console.log('onChange ', value);
setValue(newValue);
......@@ -26,6 +31,7 @@ const AddUserModal = props => {
useEffect(() => {
if (visible) {
getPasswordRule();
addUserForm.resetFields();
getEmptyRoleList();
} else {
......@@ -33,6 +39,14 @@ const AddUserModal = props => {
}
}, [orgID, visible]);
const getPasswordRule = () => {
GetPasswordRegularization().then(res => {
if (res.code === 0) {
setRules(res.data);
}
});
};
// 获取全部未勾选站点列表
const getEmptyRoleList = () => {
GetUserRelationListNew({ userID: 0 })
......@@ -262,8 +276,8 @@ const AddUserModal = props => {
label="账号密码"
rules={[
{
pattern: /^(?=.*[a-zA-Z])(?=.*\d)[\w\S]{6,16}$/,
message: '长度6-16位,必须包含数字与字母',
pattern: rules ? rules.regex : `/^(?=.*[a-zA-Z])(?=.*d)[wS]{6,16}$/`,
message: rules ? rules.tip : '长度6-16位,必须包含数字与字母',
},
{
pattern: /^(?!.*(?:SELECT|UPDATE|INSERT|AND|OR|'|"|;|--|\\)).*$/,
......
......@@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react';
import { Modal, Form, Input, notification, message, Divider } from 'antd';
import voca from 'voca';
import classNames from 'classnames';
import { editUser, updateUserPassword } from '@/services/userManage/api';
import { editUser, updateUserPassword, GetPasswordRegularization } from '@/services/userManage/api';
import sha1 from 'sha1';
import styles from './AddUserModal.less';
......@@ -19,17 +19,17 @@ const EditUserModal = props => {
const [passwordForm] = Form.useForm(); // 修改密码
const [newPasswordLevel, setNewPasswordLevel] = useState('');
const [passwordConfirmLevel, setPasswordConfirmLevel] = useState('');
const [rules, setRules] = useState();
useEffect(() => {
if (visible) {
console.log(currentUser);
getPasswordRule();
editUserForm.setFieldsValue({
loginName: voca.stripTags(currentUser.loginName),
userName: voca.stripTags(currentUser.userName),
phone: voca.stripTags(currentUser.phone) || '',
email: currentUser.email || '',
});
console.log(currentUser.password);
passwordForm.setFieldsValue({
oldPassword: currentUser.password,
newPassword: '',
......@@ -41,6 +41,14 @@ const EditUserModal = props => {
}
}, [visible]);
const getPasswordRule = () => {
GetPasswordRegularization().then(res => {
if (res.code === 0) {
setRules(res.data);
}
});
};
// 提交-编辑用户
const submitEditUser = () => {
const loginName = voca.stripTags(editUserForm.getFieldValue('loginName'));
......@@ -359,8 +367,8 @@ const EditUserModal = props => {
label="新密码"
rules={[
{
pattern: /^(?=.*[a-zA-Z])(?=.*\d)[\w\S]{6,16}$/,
message: '长度6-16位,必须包含数字与字母',
pattern: rules ? rules.regex : `/^(?=.*[a-zA-Z])(?=.*d)[wS]{6,16}$/`,
message: rules ? rules.tip : '长度6-16位,必须包含数字与字母',
},
{
pattern: /^(?!.*(?:SELECT|UPDATE|INSERT|AND|OR|'|"|;|--|\\)).*$/,
......@@ -398,8 +406,8 @@ const EditUserModal = props => {
label="确认密码"
rules={[
{
pattern: /^(?=.*[a-zA-Z])(?=.*\d)[\w\S]{6,16}$/,
message: '长度6-16位,必须包含数字与字母',
pattern: rules ? rules.regex : `/^(?=.*[a-zA-Z])(?=.*d)[wS]{6,16}$/`,
message: rules ? rules.tip : '长度6-16位,必须包含数字与字母',
},
{
pattern: /^(?!.*(?:SELECT|UPDATE|INSERT|AND|OR|'|"|;|--|\\)).*$/,
......
......@@ -186,9 +186,13 @@ export const DragGroup = params => post(`${PUBLISH_SERVICE}/UserCenter/DragGroup
// 获取所有站点
export const GetAllSite = params => get(`${PUBLISH_SERVICE}/UserCenter/GetAllSite`, params);
// 设置为主管
export const SetGroupManager = params => get(`${PUBLISH_SERVICE}/UserCenter/SetGroupManager`, params);
export const SetGroupManager = params =>
get(`${PUBLISH_SERVICE}/UserCenter/SetGroupManager`, params);
// 设置接收短信
export const ChangeSMSState = params => get(`${PUBLISH_SERVICE}/UserCenter/ChangeSMSState`, params);
// 获取用户密码验证规则
export const GetPasswordRegularization = params =>
get(`${PUBLISH_SERVICE}/UserCenter/GetPasswordRegularization`, params);
// export const DeleteOUNew = params =>
// get(`${PUBLISH_SERVICE}/UserCenter/DeleteOU`, params)
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