Skip to content

feat: add optional email/password auth for self-hosted deployments - #26

Open
AtherBilal wants to merge 1 commit into
10xapp:mainfrom
AtherBilal:feat/email-auth-self-hosted
Open

feat: add optional email/password auth for self-hosted deployments#26
AtherBilal wants to merge 1 commit into
10xapp:mainfrom
AtherBilal:feat/email-auth-self-hosted

Conversation

@AtherBilal

@AtherBilal AtherBilal commented Apr 1, 2026

Copy link
Copy Markdown

Summary

Self-hosted users currently have no way to sign in without first configuring Google or Microsoft OAuth credentials. Setting up OAuth for a local or self-hosted instance means creating a cloud project, registering redirect URIs, and managing client secrets — overhead that isn't worth it when you just want to run Core on your own infrastructure.

This PR adds an optional email/password sign-in form to the landing page, gated behind a single env var. The hosted app is completely unaffected — the form only appears when explicitly enabled.

Before (default — unchanged)

Only OAuth buttons shown. No configuration needed for hosted deployments.

After (VITE_ENABLE_EMAIL_AUTH=true)

image

Email/password form appears below OAuth, using Supabase's built-in email auth. No additional backend changes required.

Changes

  • core-web/src/components/Landing/LandingPage.tsx — email/password form with sign-in/sign-up toggle, conditionally rendered when VITE_ENABLE_EMAIL_AUTH=true
  • core-web/.env.example — documented new env var under [OPTIONAL] tier with usage guidance

Usage

# In core-web/.env
VITE_ENABLE_EMAIL_AUTH=true

Tip: For local development, disable "Enable email confirmations" in your Supabase project (Auth → Settings) to skip the verification email step. The default confirmation flow sends a link to localhost, which won't work if you open it from a different device.

Follow-up

  • InviteAcceptPage and ShareLinkResolver also have sign-in flows but only offer OAuth. Self-hosted users who receive an invite or share link would still be blocked without OAuth configured. Email auth should be extended to those surfaces in a follow-up PR.

Test plan

  • Default (no env var): only OAuth buttons shown, no email form
  • VITE_ENABLE_EMAIL_AUTH=true: email form appears below OAuth buttons with "or" divider
  • Sign up with email/password → account created, redirect to onboarding
  • Sign in with existing email/password → redirect to app
  • Error states display correctly (wrong password, invalid email)
  • Close and reopen modal → form state is reset (no stale password/errors)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added an optional build-time flag VITE_ENABLE_EMAIL_AUTH and email/password sign-in/sign-up UI/logic to the landing page SignInModal. The modal now conditionally renders email auth, manages local email/password/error/loading state, and calls signInWithEmail / signUpWithEmail from useAuthStore.

Changes

Cohort / File(s) Summary
Environment Configuration
core-web/.env.example
Added optional VITE_ENABLE_EMAIL_AUTH environment variable to toggle landing-page email/password sign-in for self-hosted deployments.
Sign-in Modal Enhancement
core-web/src/components/Landing/LandingPage.tsx
Introduced ENABLE_EMAIL_AUTH build flag, added email/password form and local state (email, password, errors, loading, isSignUp), added form submit flows that call signInWithEmail / signUpWithEmail from useAuthStore, and a toggle between sign-in and sign-up modes while preserving existing OAuth/Turnstile behavior.

Sequence Diagram(s)

sequenceDiagram
  participant User as "User (Browser)"
  participant Landing as "LandingPage / SignInModal"
  participant Auth as "useAuthStore"
  participant Supa as "Supabase / Auth Provider"

  User->>Landing: Open SignInModal
  alt ENABLE_EMAIL_AUTH enabled
    User->>Landing: Enter email & password, click Submit
    Landing->>Auth: signUpWithEmail(email,password) or signInWithEmail(...)
    Auth->>Supa: Create/Verify user, send confirmation/token
    Supa-->>Auth: Auth result or error
    Auth-->>Landing: Resolve or throw error
    Landing-->>User: Show success or emailError
  else OAuth path
    User->>Landing: Choose Google/Microsoft
    Landing->>Auth: signInWithOAuth(provider)
    Auth->>Supa: OAuth flow
    Supa-->>Auth: Token
    Auth-->>Landing: Close modal / set session
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hopping in code with a keyboard drum,

Email doors open — sign up or come!
A flag in the meadow decides the way,
Modal smiles wide for both night and day. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding optional email/password authentication for self-hosted deployments. It is concise, clear, and directly reflects the primary objective of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
core-web/src/components/Landing/LandingPage.tsx (1)

196-196: Announce auth errors to assistive tech.

The inline error text should be exposed as a live region so screen readers announce failures immediately.

♿ Suggested tweak
-                    {emailError && <p className="text-red-500 text-xs">{emailError}</p>}
+                    {emailError && (
+                      <p role="alert" aria-live="polite" className="text-red-500 text-xs">
+                        {emailError}
+                      </p>
+                    )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core-web/src/components/Landing/LandingPage.tsx` at line 196, The inline
email error rendered via the emailError conditional (the <p
className="text-red-500 text-xs">{emailError}</p> in the LandingPage component)
isn’t announced to screen readers; make it a live region by adding an
accessibility role/attributes (e.g., role="alert" or aria-live="assertive" with
aria-atomic="true") to that element so assistive tech will announce the error
immediately when emailError is set. Ensure the modification is applied where
emailError is rendered in LandingPage so the text remains visually the same but
is exposed as a live region.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core-web/src/components/Landing/LandingPage.tsx`:
- Around line 58-64: Reset the email auth component state when the modal is
closed by clearing the sensitive state variables: call setEmail(""),
setPassword(""), setEmailError(""), setIsSignUp(false) and
setEmailLoading(false) from the modal close/reset handler so stale
password/error/loading state is not preserved between modal sessions; add these
calls to whatever function closes the email auth modal (the modal close/reset
logic).

---

Nitpick comments:
In `@core-web/src/components/Landing/LandingPage.tsx`:
- Line 196: The inline email error rendered via the emailError conditional (the
<p className="text-red-500 text-xs">{emailError}</p> in the LandingPage
component) isn’t announced to screen readers; make it a live region by adding an
accessibility role/attributes (e.g., role="alert" or aria-live="assertive" with
aria-atomic="true") to that element so assistive tech will announce the error
immediately when emailError is set. Ensure the modification is applied where
emailError is rendered in LandingPage so the text remains visually the same but
is exposed as a live region.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d26f3597-223a-490c-85e4-2d39b6fe001b

📥 Commits

Reviewing files that changed from the base of the PR and between f50fda1 and 6b88c1c.

📒 Files selected for processing (2)
  • core-web/.env.example
  • core-web/src/components/Landing/LandingPage.tsx

Comment thread core-web/src/components/Landing/LandingPage.tsx
@AtherBilal AtherBilal changed the title Add optional email/password auth for self-hosted deployments feat: add optional email/password auth for self-hosted deployments Apr 1, 2026
@AtherBilal
AtherBilal force-pushed the feat/email-auth-self-hosted branch 3 times, most recently from e6bc3f1 to 38290d3 Compare April 1, 2026 16:17
The landing page only offered Google/Microsoft OAuth, which requires
third-party credentials setup. Self-hosters can now set
VITE_ENABLE_EMAIL_AUTH=true to enable an email/password form on the
sign-in modal, using Supabase's built-in email auth. Disabled by
default so the hosted app is unaffected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@AtherBilal
AtherBilal force-pushed the feat/email-auth-self-hosted branch from 38290d3 to 6f21c3b Compare April 1, 2026 16:19
@sonarqubecloud

sonarqubecloud Bot commented Apr 1, 2026

Copy link
Copy Markdown

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.

1 participant