|
@@ -9,6 +9,74 @@ import dayjs from 'dayjs'
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
|
|
+// 手动获取url中的参数,直接获取route.query的参数时如果有+号会被转义成空格
|
|
|
|
|
+const getQueryParams = (url: string) => {
|
|
|
|
|
+ const params = url.split('?')[1]
|
|
|
|
|
+ const query = {}
|
|
|
|
|
+ if (params) {
|
|
|
|
|
+ params.split('&').forEach((param) => {
|
|
|
|
|
+ const [key, value] = param.split('=')
|
|
|
|
|
+ query[key] = value
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ return query
|
|
|
|
|
+}
|
|
|
|
|
+console.log('route', route.query)
|
|
|
|
|
+const handleTokenRedirect = () => {
|
|
|
|
|
+ if (route.query.token && route.query.uname) {
|
|
|
|
|
+ const obj: any = getQueryParams(route.fullPath)
|
|
|
|
|
+ $api
|
|
|
|
|
+ .login({
|
|
|
|
|
+ uname: obj.uname,
|
|
|
|
|
+ token: obj.token
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res: any) => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ const { data } = res
|
|
|
|
|
+ if (data.msg === 'today') {
|
|
|
|
|
+ ElMessageBox.alert('Your password will expire today, please reset', 'Prompt', {
|
|
|
|
|
+ confirmButtonText: 'OK',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ confirmButtonClass: 'el-button--dark'
|
|
|
|
|
+ })
|
|
|
|
|
+ } else if (data.msg === 'last') {
|
|
|
|
|
+ ElMessageBox.alert(
|
|
|
|
|
+ `Your password will expire in${data.data}days, please reset`,
|
|
|
|
|
+ 'Prompt',
|
|
|
|
|
+ {
|
|
|
|
|
+ confirmButtonText: 'OK',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ confirmButtonClass: 'el-button--dark'
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ 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'
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+handleTokenRedirect()
|
|
|
|
|
+
|
|
|
const loginForm = ref({
|
|
const loginForm = ref({
|
|
|
username: '',
|
|
username: '',
|
|
|
password: '',
|
|
password: '',
|