feat(webui): unify first-run onboarding

Combine agreement consent and password setup into one ordered first-run flow.

Allow future steps to declare skip policy while honoring unattended deployment requirements.
This commit is contained in:
DrSmoothl committed 2026-07-31 17:39:12 +08:00
1 parent 5b68ca5bd3
commit a361ee512e
10 files changed
+936 -312

No files matched your search

@@ -0,0 +1,39 @@
export type RequiredOnboardingStepId = 'agreements' | 'password';
export interface OnboardingRequirements {
needsConsent: boolean;
mustChangePassword: boolean;
}
/**
* The server has already applied environment policy before returning these
* booleans. Accepted legal env flags therefore omit the agreement step, while
* a configured bootstrap password omits forced password rotation.
*/
export function buildRequiredOnboardingStepIds({
needsConsent,
mustChangePassword,
}: OnboardingRequirements): RequiredOnboardingStepId[] {
const steps: RequiredOnboardingStepId[] = [];
if (needsConsent) steps.push('agreements');
if (mustChangePassword) steps.push('password');
return steps;
}
export type OnboardingAdvance =
| { nextIndex: number; complete: false }
| { nextIndex: null; complete: true };
export function advanceOnboardingStep(
stepIds: readonly string[],
currentStepId: string,
): OnboardingAdvance {
const current = stepIds.indexOf(currentStepId);
if (current < 0) {
throw new Error(`Unknown onboarding step: ${currentStepId}`);
}
if (current === stepIds.length - 1) {
return { nextIndex: null, complete: true };
}
return { nextIndex: current + 1, complete: false };
}