/** * Configuration for the allauth library. * * This config serves two purposes: * 1. Define the base path for Django-initiated routes (must match HEADLESS_FRONTEND_URLS) * 2. Define where to navigate for various auth events (developer controls these) * * For JWT-based API calls, use mizan/jwt separately. */ export interface AllauthConfig { /** * Base path for Django-initiated routes (email verification, password reset, OAuth). * This must match the base path configured in Django's HEADLESS_FRONTEND_URLS. * * Example: '/auth' means Django sends users to '/auth/verify-email/{key}' */ basePath: string /** * Navigation targets for auth events. * These are the URLs/paths the developer wants users sent to. */ routes: { /** Where to go after successful authentication */ authenticated: string /** Where to go after logout */ logout: string /** Where the login page is (for "Back to login" links) */ login: string /** Where the signup page is (for "Create account" links) */ signup: string } } export const defaultConfig: AllauthConfig = { basePath: '/auth', routes: { authenticated: '/dashboard', logout: '/', login: '/login', signup: '/signup', }, } /** * Creates a config by merging provided options with defaults. */ export function createAllauthConfig(config: Partial): AllauthConfig { return { basePath: config.basePath ?? defaultConfig.basePath, routes: { ...defaultConfig.routes, ...config.routes, }, } } /** * Django-initiated flow paths (relative to basePath). * These must match what's configured in Django's HEADLESS_FRONTEND_URLS. */ export const DjangoFlowPaths = { VERIFY_EMAIL: '/verify-email', RESET_PASSWORD: '/reset-password', OAUTH_ERROR: '/oauth/error', } as const