Reputation: 4220
I have a login page that I would like for logged in users not be able to see. My component is as follow:
<template>...</template>
<script lang="ts">
...
@Component({
layout: 'fullWidth',
auth: 'guest',
components: {
Base,
BaseAuth,
}
})
export default class Login extends Vue { ... }
</script>
After login if I go to the /login
route it allows me to view the page. My nuxt configuration is as follow:
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' }
},
}
}
}
Is there any other configuration that I should do?
Upvotes: 5
Views: 2724
Reputation: 31
use this, first register the middleware then use auth.
middleware: 'auth',
auth : 'guest',
Upvotes: 3
Reputation: 111
i know it's not a real solution for the module, but what i end up doing was adding a hook on the login page:
mounted() {
if (this.$auth.loggedIn) {
return this.$router.push('/dashboard')
}
},
Upvotes: 0