Switch from SuperTokens to NextAuth.js
BREAKING CHANGE: Replace SuperTokens with NextAuth.js Why: - SuperTokens had persistent Traefik routing issues - SSL certificate not issuing correctly - Complex infrastructure (separate container) - NextAuth runs in Next.js app (simpler, no separate service) Changes: - Install next-auth, @auth/prisma-adapter, prisma - Create NextAuth API route: app/api/auth/[...nextauth]/route.ts - Add Prisma schema for NextAuth tables (users, sessions, accounts) - Update auth page to use NextAuth signIn() - Remove all SuperTokens code and dependencies - Keep same Google OAuth (just simpler integration) Benefits: - No separate auth service needed - No Traefik routing issues - Sessions stored in Montreal PostgreSQL - Simpler configuration - Battle-tested, widely used All authentication data stays in Montreal! Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
62
prisma/schema.prisma
Normal file
62
prisma/schema.prisma
Normal file
@@ -0,0 +1,62 @@
|
||||
// Prisma schema for NextAuth.js
|
||||
// This defines the database tables for authentication
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String @map("user_id")
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String @map("provider_account_id")
|
||||
refresh_token String? @db.Text
|
||||
access_token String? @db.Text
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? @db.Text
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
@@map("accounts")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique @map("session_token")
|
||||
userId String @map("user_id")
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("sessions")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
emailVerified DateTime? @map("email_verified")
|
||||
image String?
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
@@map("verification_tokens")
|
||||
}
|
||||
Reference in New Issue
Block a user