maxgui/src/router/index.js
/**
 *
 *
 * @param {Object} to - the target Route Object being navigated to.
 * @param {Object} from - the current route being navigated away from.
 * @param {Function} next - Function must be called to resolve the hook
 */
@param {Object} to - the target Route Object being navigated to.
@param {Object} from - the current route being navigated away from.
@param {Function} next - Function must be called to resolve the hook
@param { Object } to - the target Route Object being navigated to . @param { Object } from - the current route being navigated away from . @param { Function } next - Function must be called to resolve the hook
async function resolvingGuardedRoutes(to, from, next) {
    const { getCookie } = store.vue.$help
    const user = JSON.parse(localStorage.getItem('user'))
    const isAuthenticated = getCookie('token_body') && user.isLoggedIn
    if (isAuthenticated) {
        if (from.name === 'login') {
            await showLoadingOverlay(1500)
        }
        next()
    } else {
        await showLoadingOverlay(600)
        next({
            path: '/login',
            query: { redirect: to.path },
        })
    }
}
async function resolvingGuardedRoutes ( to , from , next ) { const { getCookie } = store . vue . $help const user = JSON . parse ( localStorage . getItem ( 'user' ) ) const isAuthenticated = getCookie ( 'token_body' ) && user . isLoggedIn if ( isAuthenticated ) { if ( from . name === 'login' ) { await showLoadingOverlay ( 1500 ) } next ( ) } else { await showLoadingOverlay ( 600 ) next ( { path : '/login' , query : { redirect : to . path } , } ) } }
@param {Object} to - the target Route Object being navigated to.
@param { Object } to - the target Route Object being navigated to .
// Check if user is logged in // show overlay loading screen after successfully authenticating