forked from Kong/konnect-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth): ensure redirect handler is registered when receiving 401 (K…
- Loading branch information
Showing
4 changed files
with
30 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { isAuthRoute } from '@/router/route-utils' | ||
import { NavigationFailureType, Router, isNavigationFailure } from 'vue-router' | ||
|
||
export function createRedirectHandler (router: Router, logout: (path?: string) => Promise<string>) { | ||
return async () => { | ||
if (isAuthRoute(router.currentRoute.value.name)) { | ||
// already on auth route, no need to logout or redirect | ||
return | ||
} | ||
|
||
await logout(router.currentRoute.value.fullPath) | ||
router.push({ name: 'login' }).catch((error) => { | ||
if (!isNavigationFailure(error, NavigationFailureType.duplicated)) { | ||
throw Error(error) | ||
} | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters