Files
exchange-2.0/resources/assets/vue/general/mixins/guards.js
T
2022-04-28 13:25:21 +08:00

16 lines
750 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('signup'), this.route('account.email.verification')];
return !unprotectedRoutes.includes(window.location.href);
},
isWithTokenRoute(){
return window.location.href.includes(this.route('account.password.reset'));
}
}
}