when user logging in, the this.$auth.$state.loggedIn
value stay false
and when reload the page it's work
also when user logging out, the this.$auth.$state.loggedIn
value stay true
and when reload the page it's work
this is my nuxt.config.js
:
auth: {
rewriteRedirects: false,
redirect: {
login: '/login',
logout: '/',
callback: false,
home: false
},
strategies: {
local: {
token: {
property: 'auth_token',
global: true,
required: true,
type: 'Bearer',
maxAge: 60 * 60 * 24 * 30 * 12 * 70
},
user: {
property: false
},
endpoints: {
login: { url: '/v1/token/login/', method: 'post' },
logout: false,
user: { url: '/v1/user', method: 'get' }
}
}
}
}
and login function:
const login = await this.$auth.loginWith('local', {
data: userData
}).catch((err) => {
if (!err.response) { return }
console.log(err)
switch (err.response.status) {
case 403:
this.error = 'Incorrect username/password'
break
case 401:
this.error = 'Incorrect username/password'
break
case 417:
this.error = 'Unauthorized.'
break
default:
this.error = 'Something Wrong Happend'
break
}
})
and logout function:
async onLogout () {
await this.$auth.logout()
this.$nuxt.$router.push('/')
}
nuxt versiom: "^2.15.3" @nuxtjs/auth-next versiom: "5.0.0-1648802546.c9880dc"