Fix jwt-token
This commit is contained in:
@@ -8,7 +8,7 @@ async function debugTenant() {
|
|||||||
const sequelize = new Sequelize({
|
const sequelize = new Sequelize({
|
||||||
dialect: 'sqlite',
|
dialect: 'sqlite',
|
||||||
storage: ':memory:',
|
storage: ':memory:',
|
||||||
logging: console.log
|
logging: false // Disable logging for cleaner output
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load models
|
// Load models
|
||||||
@@ -18,15 +18,51 @@ async function debugTenant() {
|
|||||||
// Sync database
|
// Sync database
|
||||||
await sequelize.sync({ force: true });
|
await sequelize.sync({ force: true });
|
||||||
|
|
||||||
console.log('Attempting to create tenant...');
|
console.log('Attempting to create tenant1...');
|
||||||
const tenant = await Tenant.create({
|
const tenant1 = await Tenant.create({
|
||||||
name: 'Debug Tenant',
|
name: 'Test Tenant 1',
|
||||||
slug: 'debug-tenant-' + Date.now(),
|
slug: 'tenant1',
|
||||||
domain: 'debug.example.com',
|
domain: 'test1.example.com',
|
||||||
is_active: true
|
is_active: true
|
||||||
});
|
});
|
||||||
|
console.log('✅ Tenant1 created successfully:', tenant1.id);
|
||||||
|
|
||||||
console.log('✅ Tenant created successfully:', tenant.id);
|
console.log('Attempting to create tenant2...');
|
||||||
|
const tenant2 = await Tenant.create({
|
||||||
|
name: 'Test Tenant 2',
|
||||||
|
slug: 'tenant2',
|
||||||
|
domain: 'test2.example.com',
|
||||||
|
is_active: true
|
||||||
|
});
|
||||||
|
console.log('✅ Tenant2 created successfully:', tenant2.id);
|
||||||
|
|
||||||
|
// Try to create a tenant with same slug (should fail)
|
||||||
|
console.log('Attempting to create duplicate slug (should fail)...');
|
||||||
|
try {
|
||||||
|
await Tenant.create({
|
||||||
|
name: 'Duplicate Tenant',
|
||||||
|
slug: 'tenant1', // This should fail
|
||||||
|
domain: 'test3.example.com',
|
||||||
|
is_active: true
|
||||||
|
});
|
||||||
|
console.log('❌ ERROR: Duplicate slug should have failed!');
|
||||||
|
} catch (error) {
|
||||||
|
console.log('✅ Correctly caught duplicate slug error:', error.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to create a tenant with same domain (should fail)
|
||||||
|
console.log('Attempting to create duplicate domain (should fail)...');
|
||||||
|
try {
|
||||||
|
await Tenant.create({
|
||||||
|
name: 'Duplicate Domain Tenant',
|
||||||
|
slug: 'tenant3',
|
||||||
|
domain: 'test1.example.com', // This should fail
|
||||||
|
is_active: true
|
||||||
|
});
|
||||||
|
console.log('❌ ERROR: Duplicate domain should have failed!');
|
||||||
|
} catch (error) {
|
||||||
|
console.log('✅ Correctly caught duplicate domain error:', error.message);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('❌ Error creating tenant:');
|
console.log('❌ Error creating tenant:');
|
||||||
|
|||||||
Reference in New Issue
Block a user