feat: 添加密码过期功能支持,密码有效期时间天
This commit is contained in:
@@ -23,6 +23,7 @@ type ModalStateType = {
|
||||
/**密码策略 */
|
||||
passwordPolicy: Record<string, any>;
|
||||
/**密码有效期 */
|
||||
passwdExpireEnable: boolean;
|
||||
passwdExpire: Record<string, any>;
|
||||
};
|
||||
|
||||
@@ -37,6 +38,7 @@ let modalState: ModalStateType = reactive({
|
||||
},
|
||||
confirmLoading: false,
|
||||
passwordPolicy: { minLength: 8, specialChars: 2, uppercase: 1, lowercase: 1 },
|
||||
passwdExpireEnable: false,
|
||||
passwdExpire: { expHours: 2, alertHours: 1 },
|
||||
});
|
||||
|
||||
@@ -74,6 +76,7 @@ function fnModalOk() {
|
||||
updateUserPasswordForce(password).then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
userStore.fnLogOut();
|
||||
modalState.confirmLoading = true;
|
||||
Modal.success({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.account.settings.submitOkTip', {
|
||||
@@ -108,7 +111,20 @@ onMounted(() => {
|
||||
}
|
||||
if (resArr[1].code === RESULT_CODE_SUCCESS) {
|
||||
try {
|
||||
modalState.passwdExpire = JSON.parse(resArr[1].data);
|
||||
const data = JSON.parse(resArr[1].data);
|
||||
if (data.expHours % 24 === 0) {
|
||||
data.expHours = data.expHours / 24;
|
||||
} else {
|
||||
data.expHours = (data.expHours / 24).toFixed(2);
|
||||
}
|
||||
if (data.alertHours % 24 === 0) {
|
||||
data.alertHours = data.alertHours / 24;
|
||||
} else {
|
||||
data.alertHours = (data.alertHours / 24).toFixed(2);
|
||||
}
|
||||
console.log(data);
|
||||
modalState.passwdExpire = data;
|
||||
modalState.passwdExpireEnable = data.expHours > 0;
|
||||
} catch (error) {
|
||||
console.error('passwdExpire', error);
|
||||
}
|
||||
@@ -155,6 +171,7 @@ onUnmounted(() => {});
|
||||
>
|
||||
<a-input-password
|
||||
v-model:value="modalState.from.password"
|
||||
:disabled="modalState.confirmLoading"
|
||||
:maxlength="26"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -163,7 +180,11 @@ onUnmounted(() => {});
|
||||
</a-input-password>
|
||||
</a-form-item>
|
||||
<a-form-item name="ok" :wrapper-col="{ offset: 6 }">
|
||||
<a-button type="primary" @click="fnModalOk()">
|
||||
<a-button
|
||||
type="primary"
|
||||
@click="fnModalOk()"
|
||||
:disabled="modalState.confirmLoading"
|
||||
>
|
||||
{{ t('common.ok') }}
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
@@ -172,7 +193,7 @@ onUnmounted(() => {});
|
||||
<a-form-item name="info" :label="t('components.ForcePasswdChange.desc')">
|
||||
<div>
|
||||
<p>
|
||||
1. {{ t('components.ForcePasswdChange.passwordPolicy') }}<br />
|
||||
{{ t('components.ForcePasswdChange.passwordPolicy') }}<br />
|
||||
{{
|
||||
t(
|
||||
'components.ForcePasswdChange.passwordPolicyMsg',
|
||||
@@ -180,12 +201,12 @@ onUnmounted(() => {});
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
<p>
|
||||
2. {{ t('components.ForcePasswdChange.passwdExpire') }}<br />
|
||||
<p v-if="modalState.passwdExpireEnable">
|
||||
{{ t('components.ForcePasswdChange.passwdExpire') }}<br />
|
||||
{{
|
||||
t('components.ForcePasswdChange.passwdExpireMsg', {
|
||||
expDay: (modalState.passwdExpire.expHours / 24).toFixed(2),
|
||||
alertDay: (modalState.passwdExpire.alertHours / 24).toFixed(2),
|
||||
expDay: modalState.passwdExpire.expHours,
|
||||
alertDay: modalState.passwdExpire.alertHours,
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user