Fix jwt-token
This commit is contained in:
58
scripts/create-tenant-db.sh
Normal file
58
scripts/create-tenant-db.sh
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Direct Database Tenant Creation
|
||||
# For when you need to create tenants via database
|
||||
|
||||
TENANT_NAME="${1:-Example Corp}"
|
||||
TENANT_SLUG="${2:-example}"
|
||||
|
||||
echo "Creating tenant in database: $TENANT_NAME"
|
||||
|
||||
# Execute in backend container
|
||||
docker exec -it drone-detection-backend node -e "
|
||||
const { Tenant, User } = require('./models');
|
||||
|
||||
async function createTenant() {
|
||||
try {
|
||||
// Create the tenant
|
||||
const tenant = await Tenant.create({
|
||||
name: '$TENANT_NAME',
|
||||
slug: '$TENANT_SLUG',
|
||||
subscription_type: 'basic',
|
||||
is_active: true,
|
||||
auth_provider: 'local',
|
||||
features: {
|
||||
max_devices: 50,
|
||||
max_users: 10,
|
||||
api_rate_limit: 5000,
|
||||
data_retention_days: 365,
|
||||
features: ['basic_detection', 'alerts', 'dashboard', 'analytics']
|
||||
},
|
||||
admin_email: 'admin@$TENANT_SLUG.com'
|
||||
});
|
||||
|
||||
console.log('✅ Tenant created:', tenant.toJSON());
|
||||
|
||||
// Create default admin user for this tenant
|
||||
const adminUser = await User.create({
|
||||
username: 'admin',
|
||||
email: 'admin@$TENANT_SLUG.com',
|
||||
password: 'admin123', // Will be hashed automatically
|
||||
role: 'admin',
|
||||
tenant_id: tenant.id,
|
||||
is_active: true
|
||||
});
|
||||
|
||||
console.log('✅ Admin user created for tenant');
|
||||
console.log('🌐 Tenant URL: https://$TENANT_SLUG.dev.uggla.uamils.com');
|
||||
console.log('🔑 Login: admin / admin123');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Error creating tenant:', error.message);
|
||||
} finally {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
createTenant();
|
||||
"
|
||||
Reference in New Issue
Block a user