Fix jwt-token

This commit is contained in:
2025-09-20 23:20:26 +02:00
parent 78fbf3a7cd
commit a93b7c07de

View File

@@ -250,24 +250,36 @@ module.exports = {
} }
} }
// Create default tenant for backward compatibility // Create default tenant for backward compatibility (only if it doesn't exist)
const defaultTenantId = await queryInterface.bulkInsert('tenants', [{ const [existingTenant] = await queryInterface.sequelize.query(
id: Sequelize.literal('gen_random_uuid()'), 'SELECT id FROM tenants WHERE slug = \'default\' LIMIT 1',
name: 'Default Organization', { type: Sequelize.QueryTypes.SELECT }
slug: 'default', );
subscription_type: 'enterprise',
is_active: true, let defaultTenantId;
auth_provider: 'local', if (!existingTenant) {
features: JSON.stringify({ console.log('🏢 Creating default tenant...');
max_devices: -1, defaultTenantId = await queryInterface.bulkInsert('tenants', [{
max_users: -1, id: Sequelize.literal('gen_random_uuid()'),
api_rate_limit: 50000, name: 'Default Organization',
data_retention_days: -1, slug: 'default',
features: ['all'] subscription_type: 'enterprise',
}), is_active: true,
created_at: new Date(), auth_provider: 'local',
updated_at: new Date() features: JSON.stringify({
}], { returning: true }); max_devices: -1,
max_users: -1,
api_rate_limit: 50000,
data_retention_days: -1,
features: ['all']
}),
created_at: new Date(),
updated_at: new Date()
}], { returning: true });
} else {
console.log('⚠️ Default tenant already exists, skipping...');
defaultTenantId = existingTenant.id;
}
// Associate existing users with default tenant // Associate existing users with default tenant
await queryInterface.sequelize.query(` await queryInterface.sequelize.query(`