fix password reset redirect bug

This commit is contained in:
omair saleh
2022-04-26 13:21:11 +08:00
parent 8e10d68257
commit 67615168f8
2 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -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 => {
+4 -5
View File
@@ -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'));
}
}