feat(auth): harden session management and security
- Implement server-side session revocation on logout - Add IP extraction utility and admin setup error handling - Improve error codes and response consistency for auth endpoints - Refine landing page redirect logic to handle transient DB outages - Update deployment documentation and configuration defaults
This commit is contained in:
1 parent
935f12a1e9
commit
89e4d68690
81 files changed
+11530
-6916
No files matched your search
+22
-4
@@ -1,5 +1,8 @@
|
||||
import { AdminSetup } from '@/components/sections/AdminSetup';
|
||||
import { isAdminSetupComplete } from '@/core/auth/adminUsers';
|
||||
import {
|
||||
isAdminSetupComplete,
|
||||
requiresPersistentAdminDatabase,
|
||||
} from '@/core/auth/adminUsers';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
@@ -7,15 +10,30 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
export default async function SetupPage() {
|
||||
let databaseReady = true;
|
||||
try {
|
||||
if (await isAdminSetupComplete()) redirect('/vcon/login');
|
||||
} catch {
|
||||
let databaseError = '';
|
||||
let setupComplete = false;
|
||||
|
||||
if (requiresPersistentAdminDatabase()) {
|
||||
databaseReady = false;
|
||||
databaseError =
|
||||
'PostgreSQL DATABASE_URL is required in production before creating an administrator account.';
|
||||
} else {
|
||||
try {
|
||||
setupComplete = await isAdminSetupComplete();
|
||||
} catch {
|
||||
databaseReady = false;
|
||||
databaseError = 'Database connection unavailable.';
|
||||
}
|
||||
}
|
||||
|
||||
if (databaseReady && setupComplete) {
|
||||
redirect('/vcon/login');
|
||||
}
|
||||
|
||||
return (
|
||||
<AdminSetup
|
||||
databaseReady={databaseReady}
|
||||
databaseError={databaseError}
|
||||
initialEmail={process.env.DATASTACK_ADMIN_EMAIL?.trim().toLowerCase() ?? ''}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user