ultisuite-client/lib/auth/login-url.ts
R3D347HR4Y 9ea2d3325d
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
feat(auth): enhance authentication flows with embedded support and UI improvements
- Updated login and signup components to utilize AuthCard for better user experience during redirection.
- Introduced AuthentikEmbedDialog for seamless integration of Authentik's identity portal within the application.
- Enhanced password recovery and signup flows with dynamic theme handling and improved loading states.
- Refactored existing components to streamline authentication processes and improve maintainability.
2026-06-21 00:12:45 +02:00

32 lines
975 B
TypeScript

/** Build OIDC login URL (full navigation — never use Next.js Link). */
export function buildOidcLoginUrl(options?: {
returnTo?: string
intent?: "add_account"
prompt?: string
}) {
const returnTo = options?.returnTo ?? "/mail/inbox"
const params = new URLSearchParams({
returnTo,
})
if (options?.intent === "add_account") {
params.set("intent", "add_account")
}
if (options?.prompt) {
params.set("prompt", options.prompt)
}
return `/api/auth/login?${params.toString()}`
}
/** Normalize BFF /flows/complete redirect (MAIL_APP_URL may wrongly include /mail). */
export function resolveAuthLoginRedirect(redirectUrl: string): string {
try {
const target = new URL(redirectUrl, window.location.origin)
if (target.pathname.startsWith("/mail/api/auth/")) {
target.pathname = target.pathname.slice("/mail".length)
}
return target.toString()
} catch {
return redirectUrl.replace(/^\/mail(?=\/api\/auth\/)/, "")
}
}