Sign-In Methods
Magic Link Email Sign-In
The primary authentication method for AdRecon is passwordless Magic Link authentication.Enter your email address
Navigate to the login page and enter the email address associated with your AdRecon account.
Submit the form
Click Send Magic Link to request a sign-in link. The system will only send a link if an account exists for that email address.
Check your inbox
If your email is registered, you’ll receive a message: “Check your inbox — if there’s an account for this email, a sign-in link is on its way.”
Magic Links are configured with
shouldCreateUser: false, meaning you must already have an account. New users cannot self-register via email.Auth.tsx:73-79):
Google OAuth Sign-In
Google OAuth is supported as an alternative authentication provider.Configure OAuth redirect
The OAuth flow redirects to your app origin at
/app after successful authentication.New user validation
When a new Google OAuth sign-in occurs, the system checks if the user was created within the last 60 seconds and verifies they have legitimate provenance.
App.tsx:218-229):
Fanbasis Purchase-Based Provisioning
Access to AdRecon is granted exclusively through Fanbasis purchases. The webhook provisioning system creates and manages user accounts automatically.Purchase Flow
Purchase on Fanbasis
When a customer completes a purchase for an enabled AdRecon offer on Fanbasis, a webhook event is fired.
Webhook validation
The webhook handler validates the event signature and secret, then extracts the buyer email and offer ID.
User creation or update
The system creates a new Supabase auth user (if needed) or updates an existing user’s metadata with
source: 'fanbasis' and user_type: 'member'.Webhook provisioning sets
user_metadata.source = 'fanbasis', which grants the user legitimate provenance for authentication.Access Revocation
If a Fanbasis payment is refunded, disputed, or charged back, the webhook handler revokes access:- Sets
user_metadata.fanbasis_access_revoked = true - Applies a long-duration auth ban
- Signs the user out on their next session check
App.tsx:150-158):
Access Control (Admin vs Member)
AdRecon uses role-based access control to gate administrative features.User Roles
| Role | Marker | Permissions |
|---|---|---|
| Admin | app_metadata.user_type = 'admin' | Full access to dashboard, profile, and admin panel |
| Member | app_metadata.user_type = 'member' or not set | Access to dashboard and profile only |
Route Protection
Admin routes (/admin, /app/admin, /admin/fanbasis, /app/admin/fanbasis) check the isAdmin state before rendering.
Admin route guard (App.tsx:306-316):
Admin API Protection
Serverless admin endpoints (/api/admin/users, /api/admin/fanbasis) validate the bearer token and check app_metadata.user_type:
200responses for admin users403responses for authenticated non-admin users401responses for unauthenticated requests
Session Management
AdRecon bootstraps and maintains authentication state using Supabase session hooks.Session Bootstrap
Initial session fetch
On app load, the client calls
supabase.auth.getSession() to retrieve the current session (if any).User metadata fetch
If a session exists, the app calls
supabase.auth.getUser() to fetch fresh app_metadata and user_metadata.App.tsx:118-166):
Auth State Listener
The app subscribes toonAuthStateChange to react to session events (sign-in, sign-out, token refresh).
Key behaviors:
SIGNED_INevents trigger new user validation (60-second provenance check)- Access revocation is re-checked on every state change
- Admin status is re-synced from fresh
app_metadata
The auth state listener runs for the entire app lifecycle and cleans up the subscription on unmount.
Sign-Out
Users can sign out from the profile page or admin dashboard header. Sign-out implementation (ProfilePage.tsx:321-332):
/app, which renders the login screen.
Security Notes
- Invite-only access: Magic Links and OAuth are disabled for new users without Fanbasis provenance.
- Session validation: Every session includes fresh
app_metadataanduser_metadatachecks. - Revocation enforcement: Refunded/disputed purchases result in immediate session termination.
- Admin route protection: Client-side route guards and server-side API guards prevent unauthorized access.