nas-samba: use SMB_PASSWORD for admin login, configurable username
This commit is contained in:
@@ -27,6 +27,8 @@ const DB_PATH = process.env.DB_PATH || '/config/cloudsync.db';
|
|||||||
const JWT_SECRET = process.env.JWT_SECRET || 'cloudsync_secret_key';
|
const JWT_SECRET = process.env.JWT_SECRET || 'cloudsync_secret_key';
|
||||||
const JWT_ALGORITHM = 'HS256';
|
const JWT_ALGORITHM = 'HS256';
|
||||||
const JWT_EXPIRATION_HOURS = 24;
|
const JWT_EXPIRATION_HOURS = 24;
|
||||||
|
const ADMIN_USERNAME = process.env.ADMIN_USERNAME || 'alexz';
|
||||||
|
const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD || process.env.SMB_PASSWORD || 'admin123';
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// SQLite setup
|
// SQLite setup
|
||||||
@@ -1464,8 +1466,8 @@ function seedAdmin() {
|
|||||||
const adminId = crypto.randomUUID();
|
const adminId = crypto.randomUUID();
|
||||||
sqlDb.prepare(
|
sqlDb.prepare(
|
||||||
'INSERT INTO users (id, username, password_hash, name, role, storage_quota, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)'
|
'INSERT INTO users (id, username, password_hash, name, role, storage_quota, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)'
|
||||||
).run(adminId, 'admin', hashPassword('admin123'), 'Administrator', 'admin', 107374182400, new Date().toISOString());
|
).run(adminId, ADMIN_USERNAME, hashPassword(ADMIN_PASSWORD), 'Administrator', 'admin', 107374182400, new Date().toISOString());
|
||||||
console.log('Default admin user created (admin/admin123)');
|
console.log(`Admin user created: ${ADMIN_USERNAME}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ directory=/app
|
|||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
priority=20
|
priority=20
|
||||||
environment=PORT="8080",UPLOAD_DIR="/nas",DB_PATH="/config/cloudsync.db",JWT_SECRET="%(ENV_JWT_SECRET)s"
|
environment=PORT="8080",UPLOAD_DIR="/nas",DB_PATH="/config/cloudsync.db",JWT_SECRET="%(ENV_JWT_SECRET)s",SMB_PASSWORD="%(ENV_SMB_PASSWORD)s"
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/stdout
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/stderr
|
||||||
|
|||||||
Reference in New Issue
Block a user