Fix jwt-token

This commit is contained in:
2025-09-15 07:18:36 +02:00
parent 8f04f21360
commit a3c12efcf0
2 changed files with 21 additions and 21 deletions

View File

@@ -197,7 +197,7 @@ class IPRestrictionMiddleware {
const TenantModel = this.models ? this.models.Tenant : Tenant;
const tenant = await TenantModel.findOne({
where: { slug: tenantId },
attributes: ['id', 'slug', 'ip_restrictions_enabled', 'allowed_ips', 'ip_restriction_message', 'updated_at']
attributes: ['id', 'slug', 'ip_restriction_enabled', 'ip_whitelist', 'ip_restriction_message', 'updated_at']
});
if (!tenant) {
console.log('🔍 IP Restriction - Tenant not found in database:', tenantId);
@@ -207,13 +207,13 @@ class IPRestrictionMiddleware {
console.log('🔍 IP Restriction - Tenant config (fresh from DB):', {
id: tenant.id,
slug: tenant.slug,
ip_restrictions_enabled: tenant.ip_restrictions_enabled,
allowed_ips: tenant.allowed_ips,
ip_restriction_enabled: tenant.ip_restriction_enabled,
ip_whitelist: tenant.ip_whitelist,
updated_at: tenant.updated_at
});
// Check if IP restrictions are enabled
if (!tenant.ip_restrictions_enabled) {
if (!tenant.ip_restriction_enabled) {
console.log('🔍 IP Restriction - Restrictions disabled for tenant');
return next();
}
@@ -229,11 +229,11 @@ class IPRestrictionMiddleware {
// Parse allowed IPs (convert string to array)
let allowedIPs = [];
if (tenant.allowed_ips) {
if (Array.isArray(tenant.allowed_ips)) {
allowedIPs = tenant.allowed_ips;
} else if (typeof tenant.allowed_ips === 'string') {
allowedIPs = tenant.allowed_ips.split(',').map(ip => ip.trim()).filter(ip => ip);
if (tenant.ip_whitelist) {
if (Array.isArray(tenant.ip_whitelist)) {
allowedIPs = tenant.ip_whitelist;
} else if (typeof tenant.ip_whitelist === 'string') {
allowedIPs = tenant.ip_whitelist.split(',').map(ip => ip.trim()).filter(ip => ip);
}
}