Skip to content

Repair a missing profile, and don't say "Profile saved" when nothing was saved - #55

Merged
nicolasmesser merged 2 commits into
mainfrom
claude/project-thread-vpgvb6
Nov 28, 2026
Merged

nicolasmesser merged 2 commits into
mainfrom
claude/project-thread-vpgvb6

Conversation

@nicolasmesser

@nicolasmesser nicolasmesser commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

During testing on 28 Nov, a sign-in user existed without a profile row: the profile had been deleted by hand, but the account was kept. Saving the name and organisation then updated nothing, yet the page said "Profile saved."

Changes

  • Profile repair. A new migration adds public.ensure_profile() (supabase/migrations/20261128000000_ensure_profile.sql). It's security definer and callable by signed-in users only. It creates the caller's own profile with the default values if it's missing, and does nothing otherwise. level and blocked stay out of users' reach, and anon can't call it.
  • The site uses it. loadProfile() (src/lib/auth.ts) calls ensure_profile() when no profile is found, then loads the profile again. This covers the account and submit pages. Normal accounts never make the call.
  • Honest save message. Saving the profile now checks how many rows it updated, and zero rows shows "We couldn't save your profile" instead of "Profile saved."
  • Tests. supabase/tests/database/ensure_profile.test.sql checks that anon is refused, that a deleted profile comes back with the defaults, and that a repeat call changes nothing.

Tested

  • Migration. Ran against a local Postgres 16 with a stand-in auth schema:
    • anon gets "permission denied".
    • A signed-in user with a deleted profile gets it back with level = standard and blocked = false.
    • A second call changes nothing.
    • Another user's profile is untouched.
  • Code. astro check, eslint and prettier pass.

Deploy order

Apply the migration to Supabase before or together with the merge. Without it, only the rare missing-profile case would show the "couldn't load" notice instead of repairing itself.

Test on live after merging

  • Save your name on the Account page, see "Profile saved.", leave the page and come back, and the name is still there.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BtKM4TZ917FEo7VwVUDwjU

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BtKM4TZ917FEo7VwVUDwjU
@netlify

netlify Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for swim-events ready!

Name Link
🔨 Latest commit 1a756e5
🔍 Latest deploy log https://app.netlify.com/projects/swim-events/deploys/6b0b181703e14dad6ece1d08
😎 Deploy Preview https://deploy-preview-55--swim-events.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BtKM4TZ917FEo7VwVUDwjU
@nicolasmesser nicolasmesser changed the title Don't say "Profile saved" when nothing was saved Repair a missing profile, and don't say "Profile saved" when nothing was saved Nov 28, 2026
@nicolasmesser
nicolasmesser merged commit d5e094d into main Nov 28, 2026
5 checks passed
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