Skip to content

Copy the staff roster name onto the account at sign-in - #47

Open
akulsharma1 wants to merge 1 commit into
mainfrom
fix/staff-display-name
Open

akulsharma1 wants to merge 1 commit into
mainfrom
fix/staff-display-name

Conversation

@akulsharma1

Copy link
Copy Markdown
Contributor

Problem

Staff added to the roster who log in to the admin site for the first time see "Welcome, null!" (e.g. Arthur). Magic-link sign-in creates their authInfo row with displayName = NULL, and the only code path that ever writes displayName is attendee registration — which staff never go through. syncRosterRoles copied roles from the roster on sign-in, but not the name.

Fix

  • API (magic-link-service.ts): syncRosterRoles now reads the staff roster row (name included). When the email is rostered it grants STAFF as before, and also writes staff.name into authInfo.displayName — guarded with .is("displayName", null) so a name set through registration is never overwritten. This runs before the JWT is minted, so even the very first login gets a token with the correct name. Existing accounts (like Arthur's) self-repair on their next login; no backfill needed.
  • Web (Home.tsx, Main.tsx): the greeting and its animation gate use truthiness instead of == "", and Main.tsx coerces the API's displayName with ?? "" before it enters the string-typed state, so a null can never render as the text "null" (also protects the navbar avatar).

Tests

  • New: first staff login copies the roster name into the JWT (displayName: "Unregistered Staff").
  • New: an existing displayName wins over the roster name.
  • Full magic-link suite passes against the local Supabase stack (27/27); web app type-checks cleanly.

🤖 Generated with Claude Code

Accounts created by magic-link sign-in start with a null displayName;
only attendee registration ever fills it in. Staff never register, so
the admin site greeted them with "Welcome, null!".

syncRosterRoles now copies staff.name into authInfo.displayName on
sign-in, but only while displayName is null so a name set through
registration is never overwritten. The admin home page and navbar also
treat a missing name as empty instead of rendering "null".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rp-monorepo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 40231cd
Status: ✅  Deploy successful!
Preview URL: https://d91fd53d.rp-monorepo.pages.dev
Branch Preview URL: https://fix-staff-display-name.rp-monorepo.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants