Authentication & Roles
Better Auth + Google OAuth
Authentication uses Better Auth with Google OAuth as the only sign-in method. Sessions are stored in Neon (HttpOnly, Secure, SameSite=Lax cookies). The auth routes are mounted at/api/auth/[...all].
First sign-in routes a new user to /onboarding to collect phone, DOB, gender,
and consents; POST /api/onboarding/complete finalises the profile. UTM and
booking context survive the OAuth redirect via sessionStorage.
RBAC — six roles
Roles are hierarchical: a higher role satisfies any lower-role requirement.Enforcing access in API routes
Two helpers guard server routes:requireSession()throws401 UNAUTHENTICATEDwhen there is no session.requireRole(minRole)throws403 FORBIDDENwhen the user’s role level is below the required minimum.
Route → role guidance
Customer endpoints live ontheroyalglow.in; admin endpoints live on the
admin.theroyalglow.in subdomain at root paths (there is no /api/admin/
segment — the subdomain is the namespace).
Public (no auth) customer endpoints:
GET theroyalglow.in/api/services,
GET /api/services/[slug], GET /api/availability, POST /api/leads,
GET /api/health.