Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/app.js
Show All 27 Lines | if (to.meta.requiresAuth && !routerState.isLoggedIn) { | ||||
// remember the original request, to use after login | // remember the original request, to use after login | ||||
routerState.afterLogin = to; | routerState.afterLogin = to; | ||||
// redirect to login page | // redirect to login page | ||||
next({ name: 'login' }) | next({ name: 'login' }) | ||||
return | return | ||||
} | } | ||||
if (routerState.isLocked && to.meta.requiresAuth && !['login', 'wallet'].includes(to.name)) { | if (routerState.isLocked && to.meta.requiresAuth && !['login', 'payment-status'].includes(to.name)) { | ||||
// redirect to the wallet page | // redirect to the payment-status page | ||||
next({ name: 'wallet' }) | next({ name: 'payment-status' }) | ||||
return | return | ||||
} | } | ||||
if (to.meta.loading) { | if (to.meta.loading) { | ||||
startLoading() | startLoading() | ||||
loadingRoute = to.name | loadingRoute = to.name | ||||
} | } | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | methods: { | ||||
if (response.email) { | if (response.email) { | ||||
this.authInfo = response | this.authInfo = response | ||||
} | } | ||||
routerState.isLocked = this.authInfo && this.authInfo.isLocked | routerState.isLocked = this.authInfo && this.authInfo.isLocked | ||||
if (dashboard !== false) { | if (dashboard !== false) { | ||||
this.$router.push(routerState.afterLogin || { name: response.redirect || 'dashboard' }) | this.$router.push(routerState.afterLogin || { name: response.redirect || 'dashboard' }) | ||||
} else if (routerState.isLocked && this.$route.name != 'wallet' && this.$route.meta.requiresAuth) { | } else if (routerState.isLocked && this.$route.meta.requiresAuth && this.$route.name != 'payment-status') { | ||||
// Always redirect locked user, here we can be after router's beforeEach handler | // Always redirect locked user, here we can be after router's beforeEach handler | ||||
this.$router.push({ name: 'wallet' }) | this.$router.push({ name: 'payment-status' }) | ||||
} | } | ||||
routerState.afterLogin = null | routerState.afterLogin = null | ||||
// Refresh the token before it expires | // Refresh the token before it expires | ||||
let timeout = response.expires_in || 0 | let timeout = response.expires_in || 0 | ||||
// We'll refresh 60 seconds before the token expires | // We'll refresh 60 seconds before the token expires | ||||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |