Fix jwt-token
This commit is contained in:
@@ -366,6 +366,8 @@ class MultiTenantAuth {
|
|||||||
try {
|
try {
|
||||||
const { User, Tenant } = this.models || require('../models');
|
const { User, Tenant } = this.models || require('../models');
|
||||||
|
|
||||||
|
console.log('🔍 validateTenantAccess called with:', { userId, tenantSlug });
|
||||||
|
|
||||||
// Find the user
|
// Find the user
|
||||||
const user = await User.findByPk(userId, {
|
const user = await User.findByPk(userId, {
|
||||||
include: [{
|
include: [{
|
||||||
@@ -374,12 +376,31 @@ class MultiTenantAuth {
|
|||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('🔍 Found user:', user ? {
|
||||||
|
id: user.id,
|
||||||
|
username: user.username,
|
||||||
|
tenant_id: user.tenant_id,
|
||||||
|
tenant: user.tenant ? {
|
||||||
|
id: user.tenant.id,
|
||||||
|
slug: user.tenant.slug,
|
||||||
|
name: user.tenant.name
|
||||||
|
} : null
|
||||||
|
} : null);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
console.log('❌ User not found');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user's tenant matches the requested tenant
|
// Check if user's tenant matches the requested tenant
|
||||||
return user.tenant && user.tenant.slug === tenantSlug;
|
const result = user.tenant && user.tenant.slug === tenantSlug;
|
||||||
|
console.log('🔍 Validation result:', {
|
||||||
|
userTenantSlug: user.tenant?.slug,
|
||||||
|
requestedSlug: tenantSlug,
|
||||||
|
result
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error validating tenant access:', error);
|
console.error('Error validating tenant access:', error);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user