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