Skip to content

Commit 4605681

Browse files
studnitzpi0
authored andcommitted
fix: regression from #385 when callback is set to false (#391)
1 parent 9cf304f commit 4605681

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/core/middleware.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,18 @@ Middleware.auth = function (ctx) {
1616

1717
const { login, callback } = ctx.$auth.options.redirect
1818
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)
19+
const insidePage = page => normalizePath(ctx.route.path) === normalizePath(page)
2120

2221
if (ctx.$auth.$state.loggedIn) {
2322
// -- Authorized --
24-
if (!login || insideLoginPage || pageIsInGuestMode) {
23+
if (!login || insidePage(login) || pageIsInGuestMode) {
2524
ctx.$auth.redirect('home')
2625
}
2726
} else {
2827
// -- Guest --
2928
// (Those passing `callback` at runtime need to mark their callback component
3029
// with `auth: false` to avoid an unnecessary redirect from callback to login)
31-
if (!pageIsInGuestMode && (!callback || insideCallbackPage)) {
30+
if (!pageIsInGuestMode && (!callback || !insidePage(callback))) {
3231
ctx.$auth.redirect('login')
3332
}
3433
}

0 commit comments

Comments
 (0)