新增重置密码以及密码复杂度
This commit is contained in:
@@ -9,7 +9,7 @@ export const REG_PHONE = /^.{3,}$/;
|
|||||||
*
|
*
|
||||||
* 6-18 characters, including letters, numbers, and underscores
|
* 6-18 characters, including letters, numbers, and underscores
|
||||||
*/
|
*/
|
||||||
export const REG_PWD = /^\w{6,18}$/;
|
export const REG_PWD = /^[\w.]{6,18}$/;
|
||||||
|
|
||||||
/** Email reg */
|
/** Email reg */
|
||||||
export const REG_EMAIL = ///^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
|
export const REG_EMAIL = ///^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import type { FormInstance } from 'ant-design-vue';
|
|||||||
import {REG_CODE_FOUR, REG_EMAIL, REG_PHONE, REG_PWD, REG_USER_NAME} from '@/constants/reg';
|
import {REG_CODE_FOUR, REG_EMAIL, REG_PHONE, REG_PWD, REG_USER_NAME} from '@/constants/reg';
|
||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
|
|
||||||
|
|
||||||
|
const regExpPasswd =/^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{6,}$/;
|
||||||
|
|
||||||
export function useFormRules() {
|
export function useFormRules() {
|
||||||
const patternRules = {
|
const patternRules = {
|
||||||
username: {
|
username: {
|
||||||
@@ -30,7 +33,12 @@ export function useFormRules() {
|
|||||||
pattern: REG_EMAIL,
|
pattern: REG_EMAIL,
|
||||||
message: $t('form.email.invalid'),
|
message: $t('form.email.invalid'),
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}
|
},
|
||||||
|
userPwd:{
|
||||||
|
pattern: regExpPasswd,
|
||||||
|
message: $t('form.pwd.invalid'),
|
||||||
|
trigger: 'change'
|
||||||
|
},
|
||||||
} satisfies Record<string, App.Global.FormRule>;
|
} satisfies Record<string, App.Global.FormRule>;
|
||||||
|
|
||||||
const formRules = {
|
const formRules = {
|
||||||
@@ -38,7 +46,8 @@ export function useFormRules() {
|
|||||||
phone: [createRequiredRule($t('form.phone.required')), patternRules.phone],
|
phone: [createRequiredRule($t('form.phone.required')), patternRules.phone],
|
||||||
pwd: [createRequiredRule($t('form.pwd.required')), patternRules.pwd],
|
pwd: [createRequiredRule($t('form.pwd.required')), patternRules.pwd],
|
||||||
code: [createRequiredRule($t('form.code.required')), patternRules.code],
|
code: [createRequiredRule($t('form.code.required')), patternRules.code],
|
||||||
email: [createRequiredRule($t('form.email.required')), patternRules.email]
|
email: [createRequiredRule($t('form.email.required')), patternRules.email],
|
||||||
|
userPwd: [createRequiredRule($t('form.pwd.required')), patternRules.userPwd],
|
||||||
} satisfies Record<string, App.Global.FormRule[]>;
|
} satisfies Record<string, App.Global.FormRule[]>;
|
||||||
|
|
||||||
/** the default required rule */
|
/** the default required rule */
|
||||||
|
|||||||
@@ -307,6 +307,8 @@ const local: any = {
|
|||||||
agreeTerms: 'I have read and agree to the User Agreement and Privacy Policy',
|
agreeTerms: 'I have read and agree to the User Agreement and Privacy Policy',
|
||||||
code:'Code',
|
code:'Code',
|
||||||
password:'Password',
|
password:'Password',
|
||||||
|
newPassword:'New Password',
|
||||||
|
oldPassword:'Old Password',
|
||||||
confirmPassword:'ConfirmPassword',
|
confirmPassword:'ConfirmPassword',
|
||||||
basicInfo: 'BasicInfo',
|
basicInfo: 'BasicInfo',
|
||||||
terms: 'Terms',
|
terms: 'Terms',
|
||||||
@@ -981,7 +983,7 @@ const local: any = {
|
|||||||
},
|
},
|
||||||
pwd: {
|
pwd: {
|
||||||
required: 'Please enter password',
|
required: 'Please enter password',
|
||||||
invalid: '6-18 characters, including letters, numbers, and underscores'
|
invalid: 'The password should contain at least uppercase and lowercase letters, numbers, special symbols, and no less than 6 digits'
|
||||||
},
|
},
|
||||||
confirmPwd: {
|
confirmPwd: {
|
||||||
required: 'Please enter password again',
|
required: 'Please enter password again',
|
||||||
|
|||||||
@@ -307,6 +307,8 @@ const local:any = {
|
|||||||
agreeTerms: '我已阅读并同意用户协议和隐私政策',
|
agreeTerms: '我已阅读并同意用户协议和隐私政策',
|
||||||
code:'验证码',
|
code:'验证码',
|
||||||
password:'密码',
|
password:'密码',
|
||||||
|
newPassword:'新密码',
|
||||||
|
oldPassword:'旧密码',
|
||||||
confirmPassword:'再次输入密码',
|
confirmPassword:'再次输入密码',
|
||||||
basicInfo: '基本信息',
|
basicInfo: '基本信息',
|
||||||
terms: '协议条款',
|
terms: '协议条款',
|
||||||
@@ -981,7 +983,7 @@ const local:any = {
|
|||||||
},
|
},
|
||||||
pwd: {
|
pwd: {
|
||||||
required: '请输入密码',
|
required: '请输入密码',
|
||||||
invalid: '密码格式不正确,6-18位字符,包含字母、数字、下划线'
|
invalid: '密码至少包含大小写字母、数字、特殊符号,且不少于6位'
|
||||||
},
|
},
|
||||||
confirmPwd: {
|
confirmPwd: {
|
||||||
required: '请输入确认密码',
|
required: '请输入确认密码',
|
||||||
|
|||||||
@@ -60,3 +60,10 @@ export function doGetUserDeptTree() {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function doUpdatePwd(pwdJson: any) {
|
||||||
|
var url= `/system/user/profile/updatePwd?oldPassword=${pwdJson.oldPassword}&newPassword=${pwdJson.newPassword}`;
|
||||||
|
return request({ url, method: 'put'});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
1
src/typings/auto-imports.d.ts
vendored
1
src/typings/auto-imports.d.ts
vendored
@@ -114,6 +114,7 @@ declare global {
|
|||||||
const doPostUser: typeof import('../service/api/user')['doPostUser']
|
const doPostUser: typeof import('../service/api/user')['doPostUser']
|
||||||
const doPutRole: typeof import('../service/api/role')['doPutRole']
|
const doPutRole: typeof import('../service/api/role')['doPutRole']
|
||||||
const doPutUser: typeof import('../service/api/user')['doPutUser']
|
const doPutUser: typeof import('../service/api/user')['doPutUser']
|
||||||
|
const doUpdatePwd: typeof import('../service/api/user')['doUpdatePwd']
|
||||||
const eagerComputed: typeof import('@vueuse/core')['eagerComputed']
|
const eagerComputed: typeof import('@vueuse/core')['eagerComputed']
|
||||||
const editRateLimit: typeof import('../service/api/auth')['editRateLimit']
|
const editRateLimit: typeof import('../service/api/auth')['editRateLimit']
|
||||||
const effectScope: typeof import('vue')['effectScope']
|
const effectScope: typeof import('vue')['effectScope']
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ const model = reactive({
|
|||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
username: patternRules.username,
|
username: patternRules.username,
|
||||||
password: patternRules.pwd
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
import { Button, Popconfirm, Tag } from 'ant-design-vue';
|
import { Button, Form, message, Popconfirm, Tag } from 'ant-design-vue';
|
||||||
import type { Key } from 'ant-design-vue/es/_util/type';
|
import type { Key } from 'ant-design-vue/es/_util/type';
|
||||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
@@ -7,6 +7,7 @@ import { enableStatusRecord } from '@/constants/business';
|
|||||||
import { SimpleScrollbar } from '~/packages/materials/src';
|
import { SimpleScrollbar } from '~/packages/materials/src';
|
||||||
import UserOperateDrawer from './modules/user-operate-drawer.vue';
|
import UserOperateDrawer from './modules/user-operate-drawer.vue';
|
||||||
import UserSearch from './modules/user-search.vue';
|
import UserSearch from './modules/user-search.vue';
|
||||||
|
import { LockOutlined } from '@ant-design/icons-vue';
|
||||||
|
|
||||||
const wrapperEl = shallowRef<HTMLElement | null>(null);
|
const wrapperEl = shallowRef<HTMLElement | null>(null);
|
||||||
const { height: wrapperElHeight } = useElementSize(wrapperEl);
|
const { height: wrapperElHeight } = useElementSize(wrapperEl);
|
||||||
@@ -96,6 +97,14 @@ const { columns, columnChecks, data, loading, getData, mobilePagination, searchP
|
|||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
)}
|
)}
|
||||||
|
{isShowBtn('system:user:resetPwd') && (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => fnRecordResetPwd(record)}
|
||||||
|
>
|
||||||
|
{$t('page.login.resetPwd.title')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -160,6 +169,89 @@ const handleReset = () => {
|
|||||||
|
|
||||||
getData();
|
getData();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**对话框对象信息状态 */
|
||||||
|
let modalState: any = reactive({
|
||||||
|
openByResetPwd: false,
|
||||||
|
title: '用户',
|
||||||
|
from: {
|
||||||
|
userName: '',
|
||||||
|
newPassword: '',
|
||||||
|
oldPassword: '',
|
||||||
|
},
|
||||||
|
confirmLoading: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**对话框内表单属性和校验规则 */
|
||||||
|
const modalStateFrom = Form.useForm(
|
||||||
|
modalState.from,
|
||||||
|
reactive({
|
||||||
|
newPassword: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
pattern: /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{6,}$/,
|
||||||
|
message: $t('form.pwd.invalid'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
oldPassword: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
pattern: /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{6,}$/,
|
||||||
|
message: $t('form.pwd.invalid'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
function fnModalOkResetPwd(){
|
||||||
|
modalStateFrom
|
||||||
|
.validate(['password'])
|
||||||
|
.then(() => {
|
||||||
|
modalState.confirmLoading = true;
|
||||||
|
const key = 'user';
|
||||||
|
const from = toRaw(modalState.from);
|
||||||
|
message.loading({ content: $t('common.loading'), key });
|
||||||
|
doUpdatePwd(from)
|
||||||
|
.then(res => {
|
||||||
|
if (!res.error) {
|
||||||
|
message.success({
|
||||||
|
content: $t('common.msgSuccess', {msg: modalState.title}),
|
||||||
|
key,
|
||||||
|
duration: 2,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getData();
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
modalState.confirmLoading = false;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
message.error($t('common.errorFields', { num: e.errorFields.length }), 3);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话框弹出关闭执行函数
|
||||||
|
* 进行表达规则校验
|
||||||
|
*/
|
||||||
|
function fnModalCancel() {
|
||||||
|
modalState.openByResetPwd = false;
|
||||||
|
modalStateFrom.resetFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话框弹出显示为 用户重置密码
|
||||||
|
* @param row 用户记录对象
|
||||||
|
*/
|
||||||
|
function fnRecordResetPwd(row: Record<string, string>) {
|
||||||
|
modalStateFrom.resetFields();
|
||||||
|
modalState.from.userName = row.userName;
|
||||||
|
modalState.title = $t('page.login.resetPwd.title');
|
||||||
|
modalState.openByResetPwd = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -213,6 +305,62 @@ const handleReset = () => {
|
|||||||
:row-data="editingData"
|
:row-data="editingData"
|
||||||
@submitted="getData"
|
@submitted="getData"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 重置密码修改框 -->
|
||||||
|
<a-modal
|
||||||
|
:keyboard="false"
|
||||||
|
:mask-closable="false"
|
||||||
|
:open="modalState.openByResetPwd"
|
||||||
|
:title="modalState.title"
|
||||||
|
:confirm-loading="modalState.confirmLoading"
|
||||||
|
@ok="fnModalOkResetPwd"
|
||||||
|
@cancel="fnModalCancel"
|
||||||
|
>
|
||||||
|
<a-form name="modalStateFromByResetPwd" layout="horizontal">
|
||||||
|
<a-form-item
|
||||||
|
:label="$t('page.manage.user.userName')"
|
||||||
|
name="userName"
|
||||||
|
v-bind="modalStateFrom.validateInfos.userName"
|
||||||
|
>
|
||||||
|
<a-input :value="modalState.from.userName" disabled :maxlength="30">
|
||||||
|
<template #prefix>
|
||||||
|
<UserOutlined />
|
||||||
|
</template>
|
||||||
|
</a-input>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item
|
||||||
|
:label="$t('page.login.register.oldPassword')"
|
||||||
|
name="password"
|
||||||
|
v-bind="modalStateFrom.validateInfos.oldPassword"
|
||||||
|
>
|
||||||
|
<a-input-password
|
||||||
|
v-model:value="modalState.from.oldPassword"
|
||||||
|
:maxlength="26"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<LockOutlined />
|
||||||
|
</template>
|
||||||
|
</a-input-password>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item
|
||||||
|
:label="$t('page.login.register.newPassword')"
|
||||||
|
name="password"
|
||||||
|
v-bind="modalStateFrom.validateInfos.newPassword"
|
||||||
|
>
|
||||||
|
<a-input-password
|
||||||
|
v-model:value="modalState.from.newPassword"
|
||||||
|
:maxlength="26"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<LockOutlined />
|
||||||
|
</template>
|
||||||
|
</a-input-password>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
|
||||||
</ACard>
|
</ACard>
|
||||||
</div>
|
</div>
|
||||||
</SimpleScrollbar>
|
</SimpleScrollbar>
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ const rules = {
|
|||||||
deptId: defaultRequiredRule,
|
deptId: defaultRequiredRule,
|
||||||
email: formRules.email,
|
email: formRules.email,
|
||||||
phonenumber: formRules.phone,
|
phonenumber: formRules.phone,
|
||||||
password: formRules.pwd,
|
password: formRules.userPwd,
|
||||||
postIds: defaultRequiredRule,
|
postIds: defaultRequiredRule,
|
||||||
roleIds: defaultRequiredRule
|
roleIds: defaultRequiredRule
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user