Add default admin credentials and improved initialization logging
This commit is contained in:
parent
6c8f9ceb63
commit
ec05cbb788
4 changed files with 54 additions and 7 deletions
|
|
@ -162,7 +162,14 @@ const initialize = () => {
|
|||
|
||||
// Create default admin user if no users exist
|
||||
db.get("SELECT COUNT(*) as count FROM users", [], (err, result) => {
|
||||
if (!err && result.count === 0) {
|
||||
if (err) {
|
||||
console.error('Error checking user count:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Database initialized. Current users: ${result.count}`);
|
||||
|
||||
if (result.count === 0) {
|
||||
const bcrypt = require('bcrypt');
|
||||
const defaultPassword = bcrypt.hashSync('admin', 10);
|
||||
|
||||
|
|
@ -172,14 +179,24 @@ const initialize = () => {
|
|||
['admin', 'admin@streamflow.local', defaultPassword, 'admin', 1],
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.error('Failed to create default admin:', err);
|
||||
console.error('❌ Failed to create default admin:', err);
|
||||
} else {
|
||||
// CWE-532: Never log passwords - even default ones
|
||||
console.log('✓ Default admin user created (username: admin)');
|
||||
console.log('⚠ SECURITY: Change the default admin password immediately!');
|
||||
console.log('');
|
||||
console.log('═══════════════════════════════════════════════════════');
|
||||
console.log('✅ Default admin user created successfully!');
|
||||
console.log('');
|
||||
console.log(' Username: admin');
|
||||
console.log(' Password: admin');
|
||||
console.log('');
|
||||
console.log('⚠️ SECURITY WARNING: Change this password immediately!');
|
||||
console.log('═══════════════════════════════════════════════════════');
|
||||
console.log('');
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
console.log('ℹ️ Users already exist. Skipping default admin creation.');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue