path correction

This commit is contained in:
sandhiya-hepl
2026-07-16 10:07:30 +05:30
parent abb35c0e03
commit 78749c860d
9 changed files with 59 additions and 412 deletions
+7 -6
View File
@@ -34,14 +34,15 @@ export function initDb() {
console.log('Seeded content database from default-content.json');
}
if (!fs.existsSync(ADMIN_FILE)) {
const password = process.env.ADMIN_PASSWORD || 'admin123';
const hash = bcrypt.hashSync(password, 12);
// Keep login credentials in sync with .env (ADMIN_USERNAME / ADMIN_PASSWORD)
const username = process.env.ADMIN_USERNAME || 'admin';
const password = process.env.ADMIN_PASSWORD || 'admin123';
if (process.env.ADMIN_USERNAME || process.env.ADMIN_PASSWORD || !fs.existsSync(ADMIN_FILE)) {
writeJson(ADMIN_FILE, {
username: process.env.ADMIN_USERNAME || 'admin',
passwordHash: hash,
username,
passwordHash: bcrypt.hashSync(password, 12),
});
console.log(`Admin user created (username: ${process.env.ADMIN_USERNAME || 'admin'})`);
console.log(`Admin credentials loaded from .env (username: ${username})`);
}
}