File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,16 @@ const isEmpty = obj => !obj || Object.keys(obj).length === 0;
290
290
const enableLogger = process . env . NODE_ENV !== 'production' ;
291
291
292
292
router . beforeEach ( async ( to , from , next ) => {
293
+ // Check if token is expired
294
+ if ( store . state . userToken ) {
295
+ const today = new Date ( )
296
+ const expirationDate = new Date ( store . state . userToken . expiration * 1000 )
297
+ if ( today > expirationDate ) {
298
+ console . info ( '- user token is expired!' )
299
+ store . commit ( 'logout' )
300
+ next ( { name : 'login' , query : { redirect : to . path } } ) ;
301
+ }
302
+ }
293
303
// next();
294
304
// if (to.meta.withNavbar) document.documentElement.classList.add('has-navbar-fixed-top');
295
305
// else document.documentElement.classList.remove('has-navbar-fixed-top');
You can’t perform that action at this time.
0 commit comments