|
|
@@ -1,6 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
|
import ErrorTips from './components/ErrorTips.vue'
|
|
|
+import FirstLoginTips from './components/FirstLoginTips.vue'
|
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
|
import ScoringSystem from '@/views/Dashboard/src/components/ScoringSystem.vue'
|
|
|
import CryptoJS from 'crypto-js'
|
|
|
@@ -30,51 +31,7 @@ const handleTokenRedirect = () => {
|
|
|
token: obj.token
|
|
|
})
|
|
|
.then((res: any) => {
|
|
|
- if (res.code === 200) {
|
|
|
- const { data } = res
|
|
|
- if (data.msg === 'today' || data.msg === 'last') {
|
|
|
- const expiredDays = data.msg === 'today' ? 'today' : `in ${data.data} days`
|
|
|
- ElMessageBox.confirm(
|
|
|
- `Your password will expire ${expiredDays}, please reset your password`,
|
|
|
- 'Prompt',
|
|
|
- {
|
|
|
- confirmButtonText: 'OK',
|
|
|
- cancelButtonText: 'Change Password',
|
|
|
- type: 'warning',
|
|
|
- confirmButtonClass: 'el-button--dark',
|
|
|
- cancelButtonClass: 'el-button--main',
|
|
|
- distinguishCancelAndClose: true
|
|
|
- }
|
|
|
- ).catch((action: any) => {
|
|
|
- if (action === 'cancel') {
|
|
|
- router.push({
|
|
|
- name: 'Reset Password'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- userStore.setUsername(res.data.uname || '')
|
|
|
- router.push('/')
|
|
|
- } else if (res.code === 400) {
|
|
|
- const { data } = res
|
|
|
- if (data.msg === 'Invalid token') {
|
|
|
- ElMessageBox.alert('Invalid token', 'Prompt', {
|
|
|
- confirmButtonText: 'OK',
|
|
|
- type: 'warning',
|
|
|
- confirmButtonClass: 'el-button--dark'
|
|
|
- })
|
|
|
- } else if (data.msg === 'passwordExpires') {
|
|
|
- ElMessageBox.alert('Password expired, please change your password', 'Prompt', {
|
|
|
- confirmButtonText: 'OK',
|
|
|
- type: 'warning',
|
|
|
- confirmButtonClass: 'el-button--dark'
|
|
|
- })
|
|
|
- userStore.setUsername(res.data.uname || '')
|
|
|
- router.push({
|
|
|
- name: 'Reset Password'
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ handleResult(res)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -215,6 +172,57 @@ const confirmVerification = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const handleResult = (res: any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ const { data } = res
|
|
|
+ if (data.msg === 'today' || data.msg === 'last') {
|
|
|
+ const expiredDays = data.msg === 'today' ? 'today' : `in ${data.data} days`
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ `Your password will expire ${expiredDays}, please reset your password`,
|
|
|
+ 'Prompt',
|
|
|
+ {
|
|
|
+ confirmButtonText: 'OK',
|
|
|
+ cancelButtonText: 'Change Password',
|
|
|
+ type: 'warning',
|
|
|
+ confirmButtonClass: 'el-button--dark',
|
|
|
+ cancelButtonClass: 'el-button--main',
|
|
|
+ distinguishCancelAndClose: true
|
|
|
+ }
|
|
|
+ ).catch((action: any) => {
|
|
|
+ if (action === 'cancel') {
|
|
|
+ router.push({
|
|
|
+ name: 'Reset Password'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ userStore.setUsername(res.data.uname || '')
|
|
|
+ router.push('/')
|
|
|
+ } else if (res.code === 400) {
|
|
|
+ const { data } = res
|
|
|
+ if (data.msg === 'Invalid token') {
|
|
|
+ ElMessageBox.alert('Invalid token', 'Prompt', {
|
|
|
+ confirmButtonText: 'OK',
|
|
|
+ type: 'warning',
|
|
|
+ confirmButtonClass: 'el-button--dark'
|
|
|
+ })
|
|
|
+ } else if (data.msg === 'passwordExpires') {
|
|
|
+ ElMessageBox.alert('Please change your password for security.', 'Prompt', {
|
|
|
+ confirmButtonText: 'Change Password',
|
|
|
+ type: 'warning',
|
|
|
+ confirmButtonClass: 'el-button--dark'
|
|
|
+ })
|
|
|
+ userStore.setUsername(res.data.uname || '')
|
|
|
+ router.push({
|
|
|
+ name: 'Reset Password'
|
|
|
+ })
|
|
|
+ } else if (data.msg === 'First login, please change your password') {
|
|
|
+ userStore.setUsername(res.data.uname, true)
|
|
|
+ firstLoginTipsRef.value.openDialog()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 验证结束后调用登录接口
|
|
|
const handleLoginAfterVerify = () => {
|
|
|
$api
|
|
|
@@ -225,53 +233,13 @@ const handleLoginAfterVerify = () => {
|
|
|
})
|
|
|
.then((res: any) => {
|
|
|
if (res.code === 200) {
|
|
|
- const { data } = res
|
|
|
if (isRememerPwd.value) {
|
|
|
saveCredentials()
|
|
|
} else {
|
|
|
clearCredentials()
|
|
|
}
|
|
|
- if (data.msg === 'today' || data.msg === 'last') {
|
|
|
- const expiredDays = data.msg === 'today' ? 'today' : `in ${data.data} days`
|
|
|
- ElMessageBox.confirm(
|
|
|
- `Your password will expire ${expiredDays}, please reset your password`,
|
|
|
- 'Prompt',
|
|
|
- {
|
|
|
- confirmButtonText: 'OK',
|
|
|
- cancelButtonText: 'Change Password',
|
|
|
- type: 'warning',
|
|
|
- confirmButtonClass: 'el-button--dark',
|
|
|
- cancelButtonClass: 'el-button--main',
|
|
|
- distinguishCancelAndClose: true
|
|
|
- }
|
|
|
- ).catch((action: any) => {
|
|
|
- if (action === 'cancel') {
|
|
|
- router.push({
|
|
|
- name: 'Reset Password'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- userStore.setUsername(res.data.uname || '')
|
|
|
- router.push('/')
|
|
|
- } else if (res.code === 400) {
|
|
|
- const { data } = res
|
|
|
- if (data.msg === 'password_error') {
|
|
|
- loginError.value.password = true
|
|
|
- } else if (data.msg === 'error_times') {
|
|
|
- errorTipsRef.value.openDialog()
|
|
|
- } else if (data.msg === 'passwordExpires') {
|
|
|
- ElMessageBox.alert('Password expired, please change your password', 'Prompt', {
|
|
|
- confirmButtonText: 'OK',
|
|
|
- type: 'warning',
|
|
|
- confirmButtonClass: 'el-button--dark'
|
|
|
- })
|
|
|
- userStore.setUsername(res.data.uname || '')
|
|
|
- router.push({
|
|
|
- name: 'Reset Password'
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
+ handleResult(res)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -337,6 +305,7 @@ const handleDeleteEmailTips = (type?: any) => {
|
|
|
}
|
|
|
|
|
|
const errorTipsRef = ref()
|
|
|
+const firstLoginTipsRef = ref()
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -472,6 +441,7 @@ const errorTipsRef = ref()
|
|
|
ref="sliderVerificationRef"
|
|
|
></VSliderVerification>
|
|
|
<ErrorTips ref="errorTipsRef" @forget-password="status = 'reset'"></ErrorTips>
|
|
|
+ <FirstLoginTips ref="firstLoginTipsRef" @forget-password="status = 'reset'"></FirstLoginTips>
|
|
|
</div>
|
|
|
</template>
|
|
|
|