feat(auth): migrate authentication layer to Supabase#5
Merged
cH0NKIIs34L merged 5 commits intomainfrom Apr 9, 2026
Merged
Conversation
The existing pull request prompt and template contained formatting inconsistencies that led to repetitive output and overlapping sections. This refinement streamlines the structure to ensure a clearer distinction between high-level summaries and implementation- specific details. This change updates the guidance for the 'How' and 'Testing' sections to prevent redundant information while ensuring reviewers get the necessary implementation context for efficient code reviews.
The `package.json` files for both the client and server were updated in a previous commit, but the corresponding `package-lock.json` files were not included. This creates a mismatch between the manifest and the locked dependency tree. This change synchronizes the lockfiles to ensure consistent installs across development and deployment environments, reflecting the recently added Supabase and testing dependencies.
The existing authApi made fetch calls to Express auth endpoints that will no longer exist after the server cleanup. This replaces all four methods with direct Supabase Auth SDK calls so the client handles auth without a backend relay.
The previous AuthProvider called a custom Express /api/auth/me endpoint on mount and managed JWT state manually. This replaces it with a Supabase onAuthStateChange subscription that keeps the client in sync with Supabase Auth automatically, and fetches the user's public.users profile row on SIGNED_IN to expose role data.
Both forms previously used fetch-based response patterns tied to
the Express auth API. This updates them to consume the { data,
error } shape returned by the new Supabase-backed authApi and
AuthProvider, and removes all Express-specific patterns.
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
Replace the Express/JWT/Passport auth stack with Supabase Auth so the
client handles authentication directly without a backend relay layer.
What Changed
client/src/modules/api/auth/auth.api.js— rewrote all four methods(signup, login, logout, checkStatus) to use Supabase Auth SDK directly
client/src/providers/AuthProvider/AuthProvider.jsx— replacedfetch-based session polling with onAuthStateChange subscription and
public.users profile fetch on SIGNED_IN
client/src/components/Forms/LoginForm/LoginForm.jsx— updated toconsume { error } from AuthProvider.login() and added isSubmitting state
client/src/components/Forms/SignupForm/SignupForm.jsx— updated toconsume { error } from authApi.signup() and added isSubmitting state
What
This PR replaces the entire client-side auth layer — authApi, AuthProvider,
LoginForm, and SignupForm — with equivalents that talk directly to Supabase
Auth instead of the Express backend.
Why
The migration to Supabase makes the Express auth endpoints (sign-up,
log-in, log-out, /me) redundant. Keeping the old fetch-based auth
layer would leave the app broken once those endpoints are removed in
Epic 4 (server cleanup), so auth must be migrated first.
How
authApinow wraps Supabase SDK methods instead of fetch — the publicsurface (signup, login, logout, checkStatus) is preserved so callers
need minimal changes
username@app.localconventionsince Supabase Auth requires an email; username is stored in
user_metadataso the DB trigger can populatepublic.usersAuthProvidersubscribes toonAuthStateChangeon mount andunsubscribes on unmount — this replaces the manual
checkAuthStatuspoll and means the client reacts to session changes in real time
SIGNED_IN, the provider fetches the user'spublic.usersrow toget
usernameandrole, since Supabase Auth itself only holds emailgetSession()is called on mount to rehydrate from localStorage beforethe first auth event fires, preventing a flash of unauthenticated state
AuthProvider.login()is now the single call site for sign-in inLoginForm— the form no longer callsauthApidirectly, keeping thesign-in flow consistent with how logout and session sync work
isSubmittingto disable the submit button duringasync calls, preventing duplicate submissions
response.ok/response.json()patterns are fully removed from bothforms — all error handling now reads from
{ error }returned by theSupabase SDK
Pre-Merge Checklist
mainbefore opening this PRnpm testin bothclient/andserver/)console.logleft in production codenpm run lint)