From 1f000aab9b698b0476a2287795a52525ac3ffab6 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:48:03 +0200 Subject: [PATCH] Rearrange BeforeEach hook - New fix for #232 --- resources/js/routes.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/resources/js/routes.js b/resources/js/routes.js index 1a217136..bde1c99b 100644 --- a/resources/js/routes.js +++ b/resources/js/routes.js @@ -82,8 +82,14 @@ router.beforeEach((to, from, next) => { // See https://github.com/garethredfern/laravel-vue/ if one day the middleware pattern // becomes relevant (i.e when some admin only pages are necessary) - if (to.name !== 'login' && to.meta.requiresAuth && ! Vue.$storage.get('authenticated', false)) { - next({ name: 'login' }) + if (to.meta.requiresAuth + && ! Vue.$storage.get('authenticated', false) + && ! window.appConfig.proxyAuth) { + next({ name: 'login' }) + } + else if (to.matched.some(record => record.meta.disabledWithAuthProxy) && window.appConfig.proxyAuth) { + // The page is not relevant with auth proxy On so we push to the main view + next({ name: 'accounts' }) } else if (to.name.startsWith('settings.')) { if (to.params.returnTo == undefined) { @@ -107,12 +113,6 @@ router.beforeEach((to, from, next) => { } else next({ name: to.name, params: {goBackTo: '/accounts'} }) } - else if (to.matched.some(record => record.meta.disabledWithAuthProxy)) { - if (window.appConfig.proxyAuth) { - next({ name: 'accounts' }) - } - else next() - } else if (to.name === 'genericError' && to.params.err == undefined) { // return to home if no err object is provided to prevent an empty error message next({ name: 'accounts' });