-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use new magic link format (#34)
* fix: use new magic link format * misc changes * added small middleware * testing something out * added new middleware * full page reload * changed middleware name + provided more comments
- Loading branch information
1 parent
7da1a93
commit dc1f16e
Showing
4 changed files
with
24 additions
and
8 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
business-registry-dashboard/app/middleware/00.magic-link.global.ts
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,16 @@ | ||
export default defineNuxtRouteMiddleware((to) => { | ||
// Check if the route is an affiliation invitation link without locale prefix | ||
if (to.path.startsWith('/affiliationInvitation/acceptToken') && !to.path.startsWith('/en-CA/')) { | ||
// Convert query params to URLSearchParams to maintain all existing query parameters | ||
const searchParams = new URLSearchParams(to.query as Record<string, string>) | ||
const queryString = searchParams.toString() | ||
|
||
// Construct the full URL with the en-CA locale prefix and existing query parameters | ||
const newUrl = `/en-CA${to.path}${queryString ? '?' + queryString : ''}` | ||
// Force a full page reload with the new URL to ensure proper locale handling | ||
window.location.href = newUrl | ||
|
||
// Prevent Nuxt from handling the navigation since we're doing a full page reload | ||
return abortNavigation() | ||
} | ||
}) |
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
2 changes: 1 addition & 1 deletion
2
...ashboard/tests/unit/pages/[token].test.ts → ...oard/tests/unit/pages/acceptToken.test.ts
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