Fix jwt-token

This commit is contained in:
2025-09-13 15:12:34 +02:00
parent e818d58499
commit d188da7812
3 changed files with 126 additions and 63 deletions

View File

@@ -7,27 +7,44 @@
module.exports = {
up: async (queryInterface, Sequelize) => {
// Add IP restriction fields
await queryInterface.addColumn('tenants', 'ip_whitelist', {
type: Sequelize.JSONB,
allowNull: true,
defaultValue: null,
comment: 'Array of allowed IP addresses/CIDR blocks for this tenant'
});
// Check if the columns already exist
const tableDescription = await queryInterface.describeTable('tenants');
if (!tableDescription.ip_whitelist) {
await queryInterface.addColumn('tenants', 'ip_whitelist', {
type: Sequelize.JSONB,
allowNull: true,
defaultValue: null,
comment: 'Array of allowed IP addresses/CIDR blocks for this tenant'
});
console.log('✅ Added ip_whitelist column to tenants table');
} else {
console.log('⚠️ Column ip_whitelist already exists, skipping...');
}
await queryInterface.addColumn('tenants', 'ip_restriction_enabled', {
type: Sequelize.BOOLEAN,
defaultValue: false,
allowNull: false,
comment: 'Whether IP restrictions are enabled for this tenant'
});
if (!tableDescription.ip_restriction_enabled) {
await queryInterface.addColumn('tenants', 'ip_restriction_enabled', {
type: Sequelize.BOOLEAN,
defaultValue: false,
allowNull: false,
comment: 'Whether IP restrictions are enabled for this tenant'
});
console.log('✅ Added ip_restriction_enabled column to tenants table');
} else {
console.log('⚠️ Column ip_restriction_enabled already exists, skipping...');
}
await queryInterface.addColumn('tenants', 'ip_restriction_message', {
type: Sequelize.TEXT,
allowNull: true,
defaultValue: 'Access denied. Your IP address is not authorized to access this tenant.',
comment: 'Custom message shown when IP access is denied'
});
if (!tableDescription.ip_restriction_message) {
await queryInterface.addColumn('tenants', 'ip_restriction_message', {
type: Sequelize.TEXT,
allowNull: true,
defaultValue: 'Access denied. Your IP address is not authorized to access this tenant.',
comment: 'Custom message shown when IP access is denied'
});
console.log('✅ Added ip_restriction_message column to tenants table');
} else {
console.log('⚠️ Column ip_restriction_message already exists, skipping...');
}
},
down: async (queryInterface, Sequelize) => {