Some checks are pending
E2E / Playwright e2e (push) Waiting to run
- Replaced LoginForm with LoginPageContent for improved login handling and user experience. - Introduced ResetPasswordPage and ResetPasswordLayout components to facilitate password reset functionality. - Added new flow stages for authentication, including PasswordStage and SourceOAuthStage, to streamline user interactions. - Updated FlowChallengeForm to integrate new stages and improve error handling during authentication processes. - Refactored existing components to support the new authentication flow structure, enhancing maintainability and user experience.
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
"use client"
|
|
|
|
import type { FlowChallenge } from "@/lib/auth/flow-api"
|
|
|
|
export type StageRendererProps = {
|
|
challenge: FlowChallenge | null
|
|
values: Record<string, string>
|
|
fieldErrors: Record<string, string>
|
|
submitting: boolean
|
|
onChange: (key: string, value: string) => void
|
|
onSubmit: (payload: Record<string, unknown>) => void | Promise<void>
|
|
}
|
|
|
|
export type StageRenderer = React.ComponentType<StageRendererProps>
|
|
|
|
export function readPrimaryAction(challenge: FlowChallenge | null): string {
|
|
const action = challenge?.primary_action
|
|
return typeof action === "string" && action.trim() ? action : "Continuer"
|
|
}
|
|
|
|
export function isKnownFlowComponent(component: string): boolean {
|
|
return component in FLOW_STAGE_REGISTRY || LEGACY_KNOWN_COMPONENTS.has(component)
|
|
}
|
|
|
|
const LEGACY_KNOWN_COMPONENTS = new Set([
|
|
"ak-stage-prompt",
|
|
"ak-stage-identification",
|
|
"ak-stage-email",
|
|
"ak-stage-authenticator-validate",
|
|
"ak-stage-password",
|
|
"ak-stage-user-login",
|
|
"ak-stage-authenticator-webauthn",
|
|
"ak-stage-source",
|
|
"xak-flow-redirect",
|
|
"ak-stage-access-denied",
|
|
])
|
|
|
|
/** Registry for Phase 3 stages. */
|
|
export const FLOW_STAGE_REGISTRY: Record<string, StageRenderer> = {}
|