feat(auth): force new Bunyip-JIT users through name onboarding #151
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
psa-systems/mokosh-server!151
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/force-profile-setup-on-jit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
upsert_user_from_oidc(JIT path for OIDC users) seeds first/last name from a synthetic email-local-part placeholder because Bunyip's at+jwt doesn't carry name claims. That leaves new users with names like "User abc12" in their topbar until they discover the Profile page and fix it. Now the SPA can gate the rest of the app behind a forced onboarding screen.Schema (migration 033): adds
users.profile_completed_at TIMESTAMPTZ(nullable). NULL means "needs onboarding", a timestamp means "name was confirmed at that moment". Existing rows backfill toNOW()so the rollout doesn't surprise-trap anyone already using mokosh.JIT semantics: the INSERT in
upsert_user_from_oidcdoes not set the column, so freshly JIT-created Bunyip users land withprofile_completed_at = NULL. The Google JIT path (PMS-138 fallback) is unchanged: it never goes throughupsert_user_from_oidcand arrives with proper names from the Google profile, so existing-row backfill keeps it covered. Legacy-login signups are also covered by the backfill.Activation:
update_user(the handler behindPUT /api/v1/auth/me) now appendsprofile_completed_at = COALESCE(profile_completed_at, NOW())to the SET clause whenever the request body carries bothfirst_nameandlast_nameas non-empty (trimmed). COALESCE preserves any prior completion timestamp, so editing your name from the Settings page after onboarding doesn't reset the activation clock.Shape exposed:
CurrentUserandUserResponseboth gain a derivedprofile_completed: bool(profile_completed_at.is_some())./api/v1/auth/meships it; the SPA reads it and decides whether to redirect to/onboarding/profile. The at+jwt middleware path that constructs a lazyCurrentUserwithout a DB hit defaultsprofile_completed: trueto avoid trapping users during the brief window between authentication and the SPA's first/mereconciliation.Backwards-compat:
CurrentUserdeserialises with#[serde(default = "default_true")]so an older serialised payload reaching a newer client (or vice versa) treats users as completed by default.Paired with the SPA-side change on mokosh-apps (
feat/force-name-onboarding), which is the actual gate UI.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.