feat: bootstrap SuperAdmin from env and lock one-time seeding
Production creates the SuperAdmin from env credentials, and dashboard seeding is authenticated, SuperAdmin-only, and locked after the first run.
This commit is contained in:
+15
-4
@@ -5,6 +5,16 @@ const path = require('path');
|
||||
|
||||
dotenv.config({ path: path.resolve(process.cwd(), '.env') });
|
||||
|
||||
const parseBool = (value, defaultValue) => {
|
||||
if (value === undefined || value === null || String(value).trim() === '') {
|
||||
return defaultValue;
|
||||
}
|
||||
const normalized = String(value).trim().toLowerCase();
|
||||
if (['true', '1', 'yes', 'on'].includes(normalized)) return true;
|
||||
if (['false', '0', 'no', 'off'].includes(normalized)) return false;
|
||||
return defaultValue;
|
||||
};
|
||||
|
||||
const config = {
|
||||
NODE_ENV: process.env.NODE_ENV || 'development',
|
||||
PORT: parseInt(process.env.PORT, 10) || 3000,
|
||||
@@ -49,10 +59,11 @@ const config = {
|
||||
// Bale Messenger Bot Settings
|
||||
BALE_BOT_TOKEN: process.env.BALE_BOT_TOKEN || 'mock_bale_bot_token',
|
||||
|
||||
// SuperAdmin Seed Settings
|
||||
SUPERADMIN_USERNAME: process.env.SUPERADMIN_USERNAME || 'superadmin',
|
||||
SUPERADMIN_PASSWORD: process.env.SUPERADMIN_PASSWORD || 'SuperAdminSecret123!',
|
||||
SUPERADMIN_EMAIL: process.env.SUPERADMIN_EMAIL || 'admin@institution.com',
|
||||
// SuperAdmin bootstrap (credentials come from env only; no hardcoded secrets)
|
||||
SUPERADMIN_ENABLED: parseBool(process.env.SUPERADMIN_ENABLED, true),
|
||||
SUPERADMIN_USERNAME: process.env.SUPERADMIN_USERNAME || '',
|
||||
SUPERADMIN_PASSWORD: process.env.SUPERADMIN_PASSWORD || '',
|
||||
SUPERADMIN_EMAIL: process.env.SUPERADMIN_EMAIL || '',
|
||||
SUPERADMIN_NATIONAL_ID: process.env.SUPERADMIN_NATIONAL_ID || '0000000000',
|
||||
SUPERADMIN_PHONE: process.env.SUPERADMIN_PHONE || '09000000000'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user