Fix jwt-token
This commit is contained in:
@@ -26,6 +26,7 @@ const Heartbeat = require('./Heartbeat')(sequelize);
|
|||||||
const User = require('./User')(sequelize);
|
const User = require('./User')(sequelize);
|
||||||
const AlertRule = require('./AlertRule')(sequelize);
|
const AlertRule = require('./AlertRule')(sequelize);
|
||||||
const AlertLog = require('./AlertLog')(sequelize);
|
const AlertLog = require('./AlertLog')(sequelize);
|
||||||
|
const Tenant = require('./Tenant')(sequelize);
|
||||||
|
|
||||||
// Define associations
|
// Define associations
|
||||||
Device.hasMany(DroneDetection, { foreignKey: 'device_id', as: 'detections' });
|
Device.hasMany(DroneDetection, { foreignKey: 'device_id', as: 'detections' });
|
||||||
@@ -43,6 +44,10 @@ AlertLog.belongsTo(AlertRule, { foreignKey: 'alert_rule_id', as: 'rule' });
|
|||||||
DroneDetection.hasMany(AlertLog, { foreignKey: 'detection_id', as: 'alerts' });
|
DroneDetection.hasMany(AlertLog, { foreignKey: 'detection_id', as: 'alerts' });
|
||||||
AlertLog.belongsTo(DroneDetection, { foreignKey: 'detection_id', as: 'detection' });
|
AlertLog.belongsTo(DroneDetection, { foreignKey: 'detection_id', as: 'detection' });
|
||||||
|
|
||||||
|
// Tenant associations
|
||||||
|
Tenant.hasMany(User, { foreignKey: 'tenant_id', as: 'users' });
|
||||||
|
User.belongsTo(Tenant, { foreignKey: 'tenant_id', as: 'tenant' });
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sequelize,
|
sequelize,
|
||||||
Device,
|
Device,
|
||||||
@@ -50,5 +55,6 @@ module.exports = {
|
|||||||
Heartbeat,
|
Heartbeat,
|
||||||
User,
|
User,
|
||||||
AlertRule,
|
AlertRule,
|
||||||
AlertLog
|
AlertLog,
|
||||||
|
Tenant
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const express = require('express');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const bcrypt = require('bcryptjs'); // Fixed: use bcryptjs instead of bcrypt
|
const bcrypt = require('bcryptjs'); // Fixed: use bcryptjs instead of bcrypt
|
||||||
|
const { Op } = require('sequelize'); // Add Sequelize operators
|
||||||
const { Tenant, User } = require('../models');
|
const { Tenant, User } = require('../models');
|
||||||
|
|
||||||
// Management-specific authentication middleware - NO shared auth with tenants
|
// Management-specific authentication middleware - NO shared auth with tenants
|
||||||
|
|||||||
Reference in New Issue
Block a user