Skip to content

Commit

Permalink
changed auth middleware to deal with token conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim committed Dec 2, 2024
1 parent 71f013b commit db476ea
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion business-registry-dashboard/app/middleware/01.auth.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ export default defineNuxtRouteMiddleware((to) => {
if (process.client) {
const { $keycloak } = useNuxtApp()
const localePath = useLocalePath()
if (to.meta.order !== 0 && !$keycloak.authenticated) {

// If it's an invitation acceptance URL, handle it differently
if (to.path.includes('/affiliationInvitation/acceptToken/')) {
// Option 1: Force reload
window.location.href = localePath('/')
return
}

// Regular auth check
if (to.meta.order !== 0 && !$keycloak.authenticated) {
return navigateTo(localePath('/'))
}
}
})

0 comments on commit db476ea

Please sign in to comment.