Skip to content

Commit

Permalink
Rearrange BeforeEach hook - New fix for #232
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubka committed Sep 19, 2023
1 parent 0ddb2e7 commit 1f000aa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions resources/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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' });
Expand Down

0 comments on commit 1f000aa

Please sign in to comment.