/** * Component: AuthTab - Authentication Settings * Documentation: documentation/settings-pages.md */ 'use client'; import { useEffect } from 'react'; import { OIDCSection } from './OIDCSection'; import { RegistrationSection } from './RegistrationSection'; import { PendingUsersTable } from './PendingUsersTable'; import { useAuthSettings } from './useAuthSettings'; import type { Settings } from '../../lib/types'; interface AuthTabProps { settings: Settings; onChange: (settings: Settings) => void; onValidationChange: (section: string, isValid: boolean) => void; onSuccess: (message: string) => void; onError: (message: string) => void; } export function AuthTab({ settings, onChange, onValidationChange, onSuccess, onError }: AuthTabProps) { const { pendingUsers, loadingPendingUsers, testing, oidcTestResult, fetchPendingUsers, testOIDCConnection, approveUser, } = useAuthSettings({ onSuccess, onError }); // Fetch pending users when the tab is loaded and registration with approval is enabled useEffect(() => { if (settings.registration.enabled && settings.registration.requireAdminApproval) { fetchPendingUsers(); } }, [settings.registration.enabled, settings.registration.requireAdminApproval, fetchPendingUsers]); const handleOIDCChange = (oidcSettings: typeof settings.oidc) => { onChange({ ...settings, oidc: oidcSettings, }); onValidationChange('oidc', false); }; const handleRegistrationChange = (registrationSettings: typeof settings.registration) => { onChange({ ...settings, registration: registrationSettings, }); onValidationChange('registration', false); }; const handleOIDCTest = async (issuerUrl: string, clientId: string, clientSecret: string) => { const isValid = await testOIDCConnection(issuerUrl, clientId, clientSecret); if (isValid) { onValidationChange('oidc', true); } return isValid; }; // Check if no auth methods are enabled and no local users exist const showNoAuthWarning = settings.backendMode === 'audiobookshelf' && !settings.oidc.enabled && !settings.registration.enabled && !settings.hasLocalUsers; // Check if registration is disabled but local users can still log in const showRegistrationDisabledInfo = settings.backendMode === 'audiobookshelf' && !settings.oidc.enabled && !settings.registration.enabled && settings.hasLocalUsers; // Show pending users table if registration with approval is enabled const showPendingUsers = settings.registration.enabled && settings.registration.requireAdminApproval; return (
You must enable at least one authentication method (OIDC or Manual Registration) since no local users exist. Saving with both disabled will lock you out of the system.
New user registration is disabled. Existing local users can still log in with their credentials.