File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -15,22 +15,20 @@ Middleware.auth = function (ctx) {
1515 }
1616
1717 const { login, callback } = ctx . app . $auth . options . redirect
18+ const pageIsInGuestMode = routeOption ( ctx . route , 'auth' , 'guest' )
19+ const insideLoginPage = normalizePath ( ctx . route . path ) === normalizePath ( login )
20+ const insideCallbackPage = normalizePath ( ctx . route . path ) !== normalizePath ( callback )
1821
1922 if ( ctx . app . $auth . $state . loggedIn ) {
2023 // -- Authorized --
21- // Redirect to home page if:
22- // - inside login page
23- // - login page disabled
24- // - options: { auth: 'guest' } is set on the page
25- if ( ! login || normalizePath ( ctx . route . path ) === normalizePath ( login ) || routeOption ( ctx . route , 'auth' , 'guest' ) ) {
24+ if ( ! login || insideLoginPage || pageIsInGuestMode ) {
2625 ctx . app . $auth . redirect ( 'home' )
2726 }
2827 } else {
2928 // -- Guest --
30- // Redirect to login page if not authorized and not inside callback page
3129 // (Those passing `callback` at runtime need to mark their callback component
3230 // with `auth: false` to avoid an unnecessary redirect from callback to login)
33- if ( ! callback || normalizePath ( ctx . route . path ) !== normalizePath ( callback ) ) {
31+ if ( ! pageIsInGuestMode && ( ! callback || insideCallbackPage ) ) {
3432 ctx . app . $auth . redirect ( 'login' )
3533 }
3634 }
You can’t perform that action at this time.
0 commit comments