Fix jwt-token
This commit is contained in:
@@ -337,33 +337,6 @@ class MultiTenantAuth {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine tenant from request (slug or subdomain)
|
|
||||||
*/
|
|
||||||
async determineTenant(req) {
|
|
||||||
try {
|
|
||||||
// Try to get tenant from subdomain first
|
|
||||||
const host = req.get('host') || '';
|
|
||||||
const subdomain = host.split('.')[0];
|
|
||||||
|
|
||||||
// If subdomain is not localhost/IP, use it as tenant slug
|
|
||||||
if (subdomain && !subdomain.match(/^(localhost|127\.0\.0\.1|\d+\.\d+\.\d+\.\d+)$/)) {
|
|
||||||
return subdomain;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback: get from user's tenant if authenticated
|
|
||||||
if (req.user && req.user.tenant_id) {
|
|
||||||
const tenant = await Tenant.findByPk(req.user.tenant_id);
|
|
||||||
return tenant ? tenant.slug : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error determining tenant:', error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that a user has access to a specific tenant
|
* Validate that a user has access to a specific tenant
|
||||||
* @param {string} userId - The user ID
|
* @param {string} userId - The user ID
|
||||||
|
|||||||
Reference in New Issue
Block a user