Add authentication layer with phone-based login (Phase 4)#9
Merged
Conversation
Implement Supabase auth that activates when DEMO_MODE=false while preserving existing demo functionality. Adds auth context, middleware route protection, login/register pages, and API route guards. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DEMO_MODE=false, preserving existing demo functionalityAuthProvidercontext that abstracts demo vs production user identity across all pages/login)customer_idwith authenticated user ID in productionNew files
src/hooks/use-auth.tsx— Auth context provider with demo/production branchingsrc/middleware.ts— Route protection middlewaresrc/app/login/page.tsx— Phone + password login pagesrc/app/register/page.tsx— Registration with role selection (customer/vendor/delivery)src/lib/auth/guard.ts— Shared server-side auth guard for API routesModified files
src/app/layout.tsx— Wrap withAuthProvidersrc/app/page.tsx— Show sign-in/register landing in production modesrc/app/checkout/page.tsx— UseuseAuth().userIdinstead ofDEMO_IDSsrc/app/vendor/page.tsx— UseuseAuth().vendorIdinstead ofDEMO_IDSsrc/app/delivery/page.tsx— UseuseAuth().deliveryPersonIdinstead ofDEMO_IDSgetAuthenticatedUser()guardTest plan
DEMO_MODE=trueworks exactly as before (role cards, hardcoded IDs, no login)DEMO_MODE=falseshows sign-in/register landing page/loginwhen unauthenticated/vendorsbrowsing works without authnpm run buildpassesnpm run lintpasses on changed filesCloses #4
🤖 Generated with Claude Code