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

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

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