diff --git a/add_stockholm_device.py b/add_stockholm_device.py index 82ed155..d612a64 100644 --- a/add_stockholm_device.py +++ b/add_stockholm_device.py @@ -54,7 +54,14 @@ def authenticate(): try: print(f"🔐 Authenticating as user: {USERNAME}") - response = requests.post(f"{API_BASE_URL}/users/login", json=login_data, verify=False) + + # Add tenant header for localhost requests + headers = {"Content-Type": "application/json"} + if "localhost" in API_BASE_URL: + headers["x-tenant-id"] = "uamils-ab" + print(f"🏢 Using tenant: uamils-ab") + + response = requests.post(f"{API_BASE_URL}/users/login", json=login_data, headers=headers, verify=False) if response.status_code == 200: data = response.json() @@ -76,15 +83,19 @@ def authenticate(): def get_auth_headers(): """Get headers with authentication token""" + headers = {"Content-Type": "application/json"} + + # Add tenant header for localhost requests + if "localhost" in API_BASE_URL: + headers["x-tenant-id"] = "uamils-ab" + if SKIP_AUTH: - return {"Content-Type": "application/json"} + return headers if AUTH_TOKEN: - return { - "Authorization": f"Bearer {AUTH_TOKEN}", - "Content-Type": "application/json" - } - return {"Content-Type": "application/json"} + headers["Authorization"] = f"Bearer {AUTH_TOKEN}" + + return headers def get_next_device_id(): """Get the next available device ID""" diff --git a/server/models/Device.js b/server/models/Device.js index 76d82b5..80e44a0 100644 --- a/server/models/Device.js +++ b/server/models/Device.js @@ -3,9 +3,9 @@ const { DataTypes } = require('sequelize'); module.exports = (sequelize) => { const Device = sequelize.define('Device', { id: { - type: DataTypes.INTEGER, + type: DataTypes.UUID, + defaultValue: sequelize.Sequelize.UUIDV4, primaryKey: true, - autoIncrement: true, allowNull: false, comment: 'Unique device identifier' },