mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-08 22:57:11 +08:00
fix: 密码过期情况下,标记用户选择是否修改密码
This commit is contained in:
@@ -98,6 +98,32 @@ const logout = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
checkPasswordExpired()
|
||||
})
|
||||
const checkPasswordExpired = () => {
|
||||
if (!userStore.passwordExpiredShow || !userStore.userInfo.passwordExpired) {
|
||||
return
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '密码已过期,是否去修改?',
|
||||
hideCancel: false,
|
||||
closable: true,
|
||||
onBeforeOk: async () => {
|
||||
try {
|
||||
await router.push({ path: '/setting/profile' })
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
onCancel: () => {
|
||||
// 当前登录会话不再提示
|
||||
userStore.passwordExpiredShow = false
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@@ -37,6 +37,7 @@ const storeSetup = () => {
|
||||
const avatar = computed(() => userInfo.avatar)
|
||||
|
||||
const token = ref(getToken() || '')
|
||||
const passwordExpiredShow = ref<boolean>(true)
|
||||
const roles = ref<string[]>([]) // 当前用户角色
|
||||
const permissions = ref<string[]>([]) // 当前角色权限标识集合
|
||||
|
||||
@@ -90,6 +91,7 @@ const storeSetup = () => {
|
||||
const logoutCallBack = async () => {
|
||||
roles.value = []
|
||||
permissions.value = []
|
||||
passwordExpiredShow.value = true
|
||||
resetToken()
|
||||
resetRouter()
|
||||
}
|
||||
@@ -112,6 +114,7 @@ const storeSetup = () => {
|
||||
token,
|
||||
roles,
|
||||
permissions,
|
||||
passwordExpiredShow,
|
||||
accountLogin,
|
||||
emailLogin,
|
||||
phoneLogin,
|
||||
@@ -124,5 +127,5 @@ const storeSetup = () => {
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore('user', storeSetup, {
|
||||
persist: { paths: ['token', 'roles', 'permissions'], storage: localStorage }
|
||||
persist: { paths: ['token', 'roles', 'permissions', 'passwordExpiredShow'], storage: localStorage }
|
||||
})
|
||||
|
@@ -94,7 +94,6 @@ const handleLogin = async () => {
|
||||
const { rememberMe } = loginConfig.value
|
||||
loginConfig.value.username = rememberMe ? form.username : ''
|
||||
Message.success('欢迎使用')
|
||||
checkPasswordExpired()
|
||||
} catch (error) {
|
||||
getCaptcha()
|
||||
form.captcha = ''
|
||||
@@ -103,26 +102,6 @@ const handleLogin = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const checkPasswordExpired = () => {
|
||||
if (!userStore.userInfo.passwordExpired) {
|
||||
return
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '密码已过期,是否去修改?',
|
||||
hideCancel: false,
|
||||
closable: true,
|
||||
onBeforeOk: async () => {
|
||||
try {
|
||||
await router.push({ path: '/setting/profile' })
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const captchaImgBase64 = ref()
|
||||
// 获取验证码
|
||||
const getCaptcha = () => {
|
||||
|
Reference in New Issue
Block a user