我有一个登录页面,我希望登录用户无法看到该页面。我的组件如下:
<template>...</template>
<script lang="ts">
...
@Component({
layout: 'fullWidth',
auth: 'guest',
components: {
Base,
BaseAuth,
}
})
export default class Login extends Vue { ... }
</script>
Run Code Online (Sandbox Code Playgroud)
登录后,如果我转到该/login路线,它允许我查看该页面。我的nuxt配置如下:
auth: {
redirect: {
login: '/login',
logout: '/',
// callback: '/login',
home: '/'
},
strategies: {
local: {
endpoints: {
login: { url: '/auth/login', method: 'post', propertyName: 'token' },
logout: { url: '/auth/logout', method: 'post' },
user: { url: '/auth/user', method: 'get', propertyName: 'user' }
},
}
}
}
Run Code Online (Sandbox Code Playgroud)
我还应该做其他配置吗?
我知道这不是该模块的真正解决方案,但我最终要做的是在登录页面上添加一个挂钩:
mounted() {
if (this.$auth.loggedIn) {
return this.$router.push('/dashboard')
}
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2623 次 |
| 最近记录: |