From 67615168f82eaa38032ef6de34ca0f31b37ce359 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 26 Apr 2022 13:21:11 +0800 Subject: [PATCH] fix password reset redirect bug --- resources/assets/vue/app.js | 2 +- resources/assets/vue/general/mixins/guards.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/assets/vue/app.js b/resources/assets/vue/app.js index cddcf3a7..d9e2e465 100644 --- a/resources/assets/vue/app.js +++ b/resources/assets/vue/app.js @@ -50,7 +50,7 @@ const app = new Vue({ store, created(){ this.routesGuard(); - if (!this.$store.getters.isAdmin && !('company_marking' in this.$store.getters.getDecodedAccessToken.user) && this.isProtectedRoute()) { + if (!this.$store.getters.isAdmin && !('company_marking' in this.$store.getters.getDecodedAccessToken.user) && this.isProtectedRoute() && !this.isWithTokenRoute()) { this.$store.dispatch('crudRequest', {endpoint: this.route('api.account.authentication.refresh'), method: 'get'}).then(response => { let success = response.ok; response.json().then(response => { diff --git a/resources/assets/vue/general/mixins/guards.js b/resources/assets/vue/general/mixins/guards.js index fd152cfe..3b39baad 100644 --- a/resources/assets/vue/general/mixins/guards.js +++ b/resources/assets/vue/general/mixins/guards.js @@ -1,16 +1,15 @@ 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') : ''; + (!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('account.password.reset')]; + const unprotectedRoutes = [this.route('login'), this.route('account.email.verification')]; return !unprotectedRoutes.includes(window.location.href); }, isWithTokenRoute(){ - const unprotectedRoutesWithToken = [this.route('account.password.reset')]; - return !window.location.href.includes(unprotectedRoutesWithToken); + return window.location.href.includes(this.route('account.password.reset')); } }