Fix jwt-token
This commit is contained in:
@@ -9,6 +9,7 @@ const {
|
|||||||
DroneDetection,
|
DroneDetection,
|
||||||
Heartbeat,
|
Heartbeat,
|
||||||
User,
|
User,
|
||||||
|
ManagementUser,
|
||||||
AlertRule,
|
AlertRule,
|
||||||
AlertLog,
|
AlertLog,
|
||||||
Tenant
|
Tenant
|
||||||
@@ -83,6 +84,36 @@ const setupDatabase = async () => {
|
|||||||
});
|
});
|
||||||
console.log(`✅ Operator user created: ${operatorUser.username}`);
|
console.log(`✅ Operator user created: ${operatorUser.username}`);
|
||||||
|
|
||||||
|
// Create management users for the management interface
|
||||||
|
console.log('👑 Creating management admin user...');
|
||||||
|
const managementAdmin = await ManagementUser.create({
|
||||||
|
username: 'admin',
|
||||||
|
email: 'admin@management.com',
|
||||||
|
first_name: 'Management',
|
||||||
|
last_name: 'Administrator',
|
||||||
|
password_hash: await bcrypt.hash('admin123', 10),
|
||||||
|
role: 'super_admin',
|
||||||
|
is_active: true,
|
||||||
|
api_access: true,
|
||||||
|
created_by: 'system'
|
||||||
|
});
|
||||||
|
console.log(`✅ Management admin created: ${managementAdmin.username}`);
|
||||||
|
|
||||||
|
// Create management tenant admin user
|
||||||
|
console.log('👑 Creating management tenant admin user...');
|
||||||
|
const managementTenantAdmin = await ManagementUser.create({
|
||||||
|
username: 'tenant_admin',
|
||||||
|
email: 'tenant_admin@management.com',
|
||||||
|
first_name: 'Tenant',
|
||||||
|
last_name: 'Administrator',
|
||||||
|
password_hash: await bcrypt.hash('tenant123', 10),
|
||||||
|
role: 'tenant_admin',
|
||||||
|
is_active: true,
|
||||||
|
api_access: true,
|
||||||
|
created_by: 'system'
|
||||||
|
});
|
||||||
|
console.log(`✅ Management tenant admin created: ${managementTenantAdmin.username}`);
|
||||||
|
|
||||||
// Create sample devices
|
// Create sample devices
|
||||||
console.log('📡 Creating sample devices...');
|
console.log('📡 Creating sample devices...');
|
||||||
const devices = await Device.bulkCreate([
|
const devices = await Device.bulkCreate([
|
||||||
@@ -313,15 +344,18 @@ const setupDatabase = async () => {
|
|||||||
|
|
||||||
console.log('🎉 Database setup completed successfully!\n');
|
console.log('🎉 Database setup completed successfully!\n');
|
||||||
console.log('📋 Summary:');
|
console.log('📋 Summary:');
|
||||||
console.log(` • Users created: 2 (admin, operator)`);
|
console.log(` • Tenant users created: 2 (admin, operator)`);
|
||||||
|
console.log(` • Management users created: 2 (admin, tenant_admin)`);
|
||||||
console.log(` • Devices created: ${devices.length}`);
|
console.log(` • Devices created: ${devices.length}`);
|
||||||
console.log(` • Heartbeats created: ${heartbeats.length}`);
|
console.log(` • Heartbeats created: ${heartbeats.length}`);
|
||||||
console.log(` • Detections created: ${detections.length}`);
|
console.log(` • Detections created: ${detections.length}`);
|
||||||
console.log(` • Alert rules created: ${alertRules.length}`);
|
console.log(` • Alert rules created: ${alertRules.length}`);
|
||||||
console.log(` • Alert logs created: ${alertLogs.length}`);
|
console.log(` • Alert logs created: ${alertLogs.length}`);
|
||||||
console.log('\n📝 Default login credentials:');
|
console.log('\n📝 Default login credentials:');
|
||||||
console.log(' Admin: admin / admin123');
|
console.log(' Tenant Admin: admin / admin123');
|
||||||
console.log(' Operator: operator / operator123\n');
|
console.log(' Tenant Operator: operator / operator123');
|
||||||
|
console.log(' Management Admin: admin / admin123');
|
||||||
|
console.log(' Management Tenant Admin: tenant_admin / tenant123\n');
|
||||||
|
|
||||||
// Close connection
|
// Close connection
|
||||||
await sequelize.close();
|
await sequelize.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user