Skip to content

fix: Supabase RLS, storage, auth, and week cycle bugs - #53

Draft
SaharPak wants to merge 1 commit into
mainfrom
cursor/fix-supabase-bugs-44a5
Draft

fix: Supabase RLS, storage, auth, and week cycle bugs#53
SaharPak wants to merge 1 commit into
mainfrom
cursor/fix-supabase-bugs-44a5

Conversation

@SaharPak

Copy link
Copy Markdown
Owner

Summary

Fixes production bugs across Supabase (RLS, storage, week logic) and the Next.js app (auth, validation, error handling).

Database migrations (run in Supabase SQL Editor)

Migration What it teaches / fixes
004_storage_product_images.sql Storage RLS — bucket + upload/read policies scoped to products/{user_id}/…
005_rls_fixes.sql Row Level Security — builders read own hidden products; votes/comments only on live products; demo archive visibility
006_current_week_cycle.sql DB functionscurrent_week() matches Sat–Fri Helsinki cycle (same as app)

App fixes

  • Auth: Callback no longer skips onboarding on Cloudflare; open redirects blocked; onboarding enforced until handle is set
  • Week cycle: Weekend submissions roll to next week; Friday demo picker aligned with countdown
  • Submit: Live demos require a Friday slot; removed silent fallback that dropped demo fields
  • Cron: Returns 500 on upsert failures instead of false success
  • Admin: Product status errors surfaced; demo days list refreshes after snapshot
  • Security: Server uses getUser() instead of getSession(); vote errors shown to users
  • Build: App builds without Supabase env vars (mock mode placeholders)

How to apply

  1. Merge this PR and deploy
  2. In Supabase SQL Editor, run migrations 004 → 005 → 006 in order (001–003 assumed already applied)
  3. Smoke test: sign up → onboarding → submit with image → vote → hide product as admin → owner can still edit
Open in Web Open in Cursor 

Database (migrations 004–006):
- Add product-images storage bucket with per-user upload policies
- Let builders read own hidden products; expose demo archive products
- Restrict votes/comments to live products; cap profile bio length
- Align current_week() SQL with Sat–Fri Helsinki submission cycle

App fixes:
- Fix auth callback overwriting onboarding redirect on Cloudflare
- Block open redirects; enforce onboarding until handle is set
- Fix weekend week_of roll-forward; sync Friday demo date picker
- Require demo_week for live demos; remove silent migration fallback
- Cron and admin snapshot error handling; refresh demo days list
- Use getUser() on server; show vote errors; safe JSON parse for builder
- Owners can view hidden products; build without Supabase env vars

Co-authored-by: Sahar <SaharPak@users.noreply.github.com>
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