Skip to content

feat(auth): setup better-auth backend with email and oauth support#7

Merged
Nirbhay21 merged 1 commit into
mainfrom
feature/setup-better-auth
Feb 3, 2026
Merged

feat(auth): setup better-auth backend with email and oauth support#7
Nirbhay21 merged 1 commit into
mainfrom
feature/setup-better-auth

Conversation

@Nirbhay21
Copy link
Copy Markdown
Owner

Summary

  • Integrated Better Auth on the backend with email/password and OAuth support
  • Introduced auth database schema with sessions, accounts, users, and verification
  • Added signup metadata validation aligned with frontend contract
  • Enabled Row Level Security (RLS) and policies for auth tables

Scope

Backend authentication setup only:

  • Better Auth server configuration
  • Auth database schema, migrations, and policies
  • Email/password and OAuth (Google, GitHub) providers
  • Signup metadata validation (role, terms acceptance)

Context

SmartAssess frontend already relies on Better Auth and expects:

  • Explicit user metadata (role, termsAccepted)
  • OAuth signup support with additional data
  • Session-based authentication

This PR establishes the backend foundation required to support that contract.

What

  • Added Better Auth server configuration with Drizzle adapter
  • Introduced auth schema with:
    • user, session, account, and verification tables
    • Proper relations and indexes
  • Implemented signup metadata validation and enforcement:
    • Role validation
    • Mandatory terms acceptance with versioning
  • Enabled Row Level Security (RLS) and defined policies for all auth tables
  • Added OAuth providers (Google, GitHub) with secure callbacks
  • Centralized environment variables (.env) validation using Zod
  • Cleaned up legacy schema and removed unused demo tables
  • Updated Drizzle config and migration structure

Testing

  • Email signup tested via frontend
  • OAuth signup tested for Google and GitHub
  • User metadata (role, termsAccepted, timestamps) verified in database
  • Session creation and persistence validated

@Nirbhay21 Nirbhay21 merged commit 501aaa4 into main Feb 3, 2026
1 check passed
@Nirbhay21 Nirbhay21 deleted the feature/setup-better-auth branch February 3, 2026 14:32
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