mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
20 lines
999 B
JavaScript
Vendored
20 lines
999 B
JavaScript
Vendored
export default {
|
|
methods: {
|
|
routesGuard(){
|
|
(!this.$store.getters.isAuthenticated && this.isProtectedRoute()&& this.isWithTokenRoute()) ? window.location.href = this.route('login') : '';
|
|
(this.$store.getters.isAuthenticated && !this.isProtectedRoute()&& this.isWithTokenRoute()) ? window.location.href = this.route('dashboard') : '';
|
|
},
|
|
isProtectedRoute(){
|
|
const unprotectedRoutes = [this.route('login'), this.route('account.email.verification'), this.route('company.claim'), this.route('last_mile_delivery.login')];
|
|
if(window.location.href.indexOf(this.route('company.claim')) === 0) {
|
|
return false;
|
|
}
|
|
return !unprotectedRoutes.includes(window.location.href);
|
|
},
|
|
isWithTokenRoute(){
|
|
const unprotectedRoutesWithToken = [this.route('account.password.reset')];
|
|
return !window.location.href.includes(unprotectedRoutesWithToken);
|
|
}
|
|
}
|
|
|
|
} |