Skip to content

Commit 4acdcae

Browse files
committed
fix: nuxt auth logout and reset cookie
1 parent 9d2da7c commit 4acdcae

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

nuxt.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ module.exports = {
4848
home: '/',
4949
callback: false,
5050
logout: '/'
51-
}
51+
},
52+
plugins: [{ src: '~/plugins/axios', ssr: true }]
5253
},
5354
moment: {
5455
defaultLocale: 'fr',
@@ -68,7 +69,6 @@ module.exports = {
6869
** Plugins to load before mounting the App
6970
*/
7071
plugins: [
71-
'~/plugins/axios',
7272
'~/plugins/notifications',
7373
'~/plugins/validator'
7474
],

plugins/axios.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ const axios: Plugin = ({$axios, redirect, $auth, app}) => {
2020

2121
if ([401, 403].includes(status) && app.router && app.router.currentRoute.path !== '/login') {
2222

23-
if($auth.loggedIn) {
24-
await $auth.logout();
25-
}
23+
if($auth.loggedIn) await $auth.logout();
24+
else await $auth.reset();
2625

2726
redirect(status, "/login");
2827
} else {

0 commit comments

Comments
 (0)