fix: 密码到期提示在刷新浏览器之后消失

This commit is contained in:
fit2cloud-chenyw 2024-04-26 20:38:14 +08:00
parent 1c9e19e891
commit 574b13b266
5 changed files with 16 additions and 1 deletions

View File

@ -173,6 +173,7 @@ export default {
default_login: 'Normal'
},
commons: {
pwd_will_expired: 'The password will expire in %s days. To avoid any disruption to your normal use, please update it promptly!',
component: {
input: 'Input',
textarea: 'Textarea',

View File

@ -173,6 +173,7 @@ export default {
default_login: '普通登錄'
},
commons: {
pwd_will_expired: '密碼將於%s天後過期為了不影響正常使用請及時進行修改',
component: {
input: '單行輸入',
textarea: '多行輸入',

View File

@ -173,6 +173,7 @@ export default {
default_login: '普通登录'
},
commons: {
pwd_will_expired: '密码将于%s天后过期为了不影响正常使用请及时进行修改',
component: {
input: '单行输入',
textarea: '多行输入',

View File

@ -29,11 +29,21 @@ export default {
},
computed: {
pwdPeriodWarn() {
if (localStorage.getItem('pwd-period-warn')) {
return true
}
return this.$store.state.user.validityPeriod > 0 && this.$store.state.user.validityPeriod < 8
},
warnMsg() {
if (localStorage.getItem('pwd-period-warn')) {
const timeText = localStorage.getItem('pwd-period-warn')
const temp = this.$t('commons.pwd_will_expired')
return temp.replace('%s', timeText)
}
if (this.$store.state.user.validityPeriod > 0 && this.$store.state.user.validityPeriod < 8) {
return `密码将于${this.$store.state.user.validityPeriod}后过期,为了不影响正常使用,请及时进行修改!`
localStorage.setItem('pwd-period-warn', this.$store.state.user.validityPeriod)
const temp = this.$t('commons.pwd_will_expired')
return temp.replace('%s', this.$store.state.user.validityPeriod)
}
return null
}

View File

@ -98,6 +98,7 @@ const actions = {
commit('SET_PASSWORD_MODIFIED', passwordModified)
localStorage.setItem('passwordModified', passwordModified)
commit('SET_VALIDITY_PERIOD', data.validityPeriod)
localStorage.removeItem('pwd-period-warn')
resolve()
}).catch(error => {
error?.response?.data?.message?.startsWith('pwdValidityPeriod') && commit('SET_LOGIN_MSG', '密码已过期,请联系管理员进行密码重置!')
@ -174,6 +175,7 @@ const actions = {
commit('RESET_STATE')
resolve(customLogoutUrl || res.data)
localStorage.removeItem('passwordModified')
localStorage.removeItem('pwd-period-warn')
}).catch(error => {
reject(error)
if (error?.response?.data?.message) {