Files
ketopath/packages/auth/src/server.ts
T
lucianoandClaude Opus 4.7 ac2227fdec feat(web): adopt shadcn/ui primitives for auth surface
Add shadcn/ui plumbing:
- components.json (style: new-york, baseColor: slate, primary: green ~142 71%)
- src/lib/utils.ts with cn() helper (clsx + tailwind-merge)
- Tailwind config switched to CSS variables theming with primary/destructive/
  muted/card etc. tokens, dark-mode class, tailwindcss-animate plugin
- src/styles/globals.css declares :root and .dark variable palettes

Initial component set under src/components/ui:
- Button (cva variants: default/destructive/outline/secondary/ghost/link, asChild)
- Input
- Label (Radix Label)
- Card + CardHeader/Title/Description/Content/Footer

Refactor existing auth surface to the new primitives:
- sign-in / sign-up pages wrap form in a Card with Title/Description (+ footer
  for sign-up disclaimer)
- sign-in-form / sign-up-form use Input, Label, Button; tokens replace bespoke
  emerald/slate classes; divider and "Continua con Google" use the same Button
- Home page CTAs become Button asChild around Link; SignOutButton uses Button
- Hide-Google logic still works: enabledSocialProviders is now
  ReadonlyArray<SocialProvider> for ergonomic .includes() checks

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 14:09:59 +02:00

48 lines
1.3 KiB
TypeScript

import { prisma } from '@ketopath/db';
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { readAuthEnv } from './env.js';
const env = readAuthEnv();
const isGoogleConfigured = Boolean(env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET);
export type SocialProvider = 'google';
export const enabledSocialProviders: ReadonlyArray<SocialProvider> = isGoogleConfigured
? ['google']
: [];
const googleProvider = isGoogleConfigured
? {
google: {
clientId: env.GOOGLE_CLIENT_ID!,
clientSecret: env.GOOGLE_CLIENT_SECRET!,
},
}
: undefined;
export const auth = betterAuth({
database: prismaAdapter(prisma, { provider: 'postgresql' }),
secret: env.BETTER_AUTH_SECRET,
baseURL: env.BETTER_AUTH_URL,
emailAndPassword: {
enabled: true,
// MVP: nessuna verifica email per non bloccare l'onboarding (vedi
// docs/decisions/0001-auth-provider.md). Verrà attivata in V1.
requireEmailVerification: false,
minPasswordLength: 8,
},
socialProviders: googleProvider,
session: {
expiresIn: 60 * 60 * 24 * 7, // 7 giorni
updateAge: 60 * 60 * 24, // refresh expiresAt ogni 24h se la session è attiva
},
advanced: {
cookiePrefix: 'ketopath',
},
});
export type Auth = typeof auth;