The access cookie expires after 15 minutes and redirects the user to the login. But now I have to delete the cookie and empty the store as I did with the logout functionality.
I used js-cookie for handling cookies.
//router
router.beforeEach((to, from, next) => {
const publicPages = ['/login', '/forgot-password', '/recover-password', 'email-forgot-password'];
const authRequired = !publicPages.includes(to.path);
const loggedIn = AuthService.getAccessToken();
if (authRequired && !loggedIn) {
next('/login');
} else {
next();
}
});
//store
setLogout(state) {
state.user = {}
state.company = {}
state.wallet = null
state.intWallet = []
state.extWallet = []
state.extWalletForWithdraw = []
state.transactions = []
state.movements = []
state.token = null
state.newTransaction = {
fromWallet: null,
toWallet: null,
amount: 0,
}
}
},
actions: {
logout(ctx) {
//console.log(ctx)
ctx.commit('setLogout')
authService.deleteAccessToken()
Company().deleteCompanyToken()
}
}