Fix jwt-token

This commit is contained in:
2025-09-22 06:02:41 +02:00
parent 1ed5edad0c
commit 69081233e0
2 changed files with 49 additions and 41 deletions

View File

@@ -582,7 +582,7 @@ module.exports = {
comment: 'Alert priority level'
},
min_threat_level: {
type: Sequelize.ENUM('monitoring', 'low', 'medium', 'high', 'critical'),
type: Sequelize.ENUM('monitoring', 'low', 'medium', 'high', 'critical'),
allowNull: true,
comment: 'Minimum threat level required to trigger alert'
},

View File

@@ -199,61 +199,69 @@ const setupDatabase = async () => {
const alertRules = await AlertRule.bulkCreate([
{
user_id: adminUser.id,
tenant_id: defaultTenant.id,
name: 'Critical Security Threat',
description: 'Immediate alert for critical and high threats to government facilities',
conditions: {
min_threat_level: 'high',
rssi_threshold: -55,
max_distance: 200,
drone_types: [0, 1, 2],
device_ids: []
},
actions: {
sms: true,
phone_number: '+46701234567',
email: true,
channels: ['sms', 'email']
},
cooldown_minutes: 2,
is_active: true,
tenant_id: defaultTenant.id
device_ids: [],
drone_types: [0, 1, 2],
min_rssi: -55,
max_rssi: null,
frequency_ranges: null,
time_window: 300,
min_detections: 1,
cooldown_period: 120,
alert_channels: ['sms', 'email'],
sms_phone_number: '+46701234567',
webhook_url: null,
active_hours: null,
active_days: [1, 2, 3, 4, 5, 6, 7],
priority: 'high',
min_threat_level: 'high'
},
{
user_id: operatorUser.id,
tenant_id: defaultTenant.id,
name: 'Medium Threat Monitoring',
description: 'Monitor medium threat drones in facility vicinity',
conditions: {
min_threat_level: 'medium',
rssi_threshold: -70,
max_distance: 1000,
drone_types: [1, 2],
device_ids: ['device-alpha-001', 'device-beta-002']
},
actions: {
sms: true,
phone_number: '+46709876543',
channels: ['sms']
},
cooldown_minutes: 10,
is_active: true,
tenant_id: defaultTenant.id
device_ids: ['device-alpha-001', 'device-beta-002'],
drone_types: [1, 2],
min_rssi: -70,
max_rssi: null,
frequency_ranges: null,
time_window: 300,
min_detections: 1,
cooldown_period: 600,
alert_channels: ['sms'],
sms_phone_number: '+46709876543',
webhook_url: null,
active_hours: null,
active_days: [1, 2, 3, 4, 5, 6, 7],
priority: 'medium',
min_threat_level: 'medium'
},
{
user_id: adminUser.id,
tenant_id: defaultTenant.id,
name: 'Device Offline Alert',
description: 'Alert when security devices go offline',
conditions: {
device_offline: true,
device_ids: ['device-alpha-001', 'device-beta-002', 'device-gamma-003']
},
actions: {
sms: true,
phone_number: '+46701234567',
channels: ['sms']
},
cooldown_minutes: 30,
is_active: true,
tenant_id: defaultTenant.id
device_ids: ['device-alpha-001', 'device-beta-002', 'device-gamma-003'],
drone_types: null,
min_rssi: null,
max_rssi: null,
frequency_ranges: null,
time_window: 300,
min_detections: 1,
cooldown_period: 1800,
alert_channels: ['sms'],
sms_phone_number: '+46701234567',
webhook_url: null,
active_hours: null,
active_days: [1, 2, 3, 4, 5, 6, 7],
priority: 'medium',
min_threat_level: null
}
]);
console.log(`✅ Created ${alertRules.length} sample alert rules`);