Fix jwt-token
This commit is contained in:
@@ -54,7 +54,14 @@ def authenticate():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
print(f"🔐 Authenticating as user: {USERNAME}")
|
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:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
@@ -76,15 +83,19 @@ def authenticate():
|
|||||||
|
|
||||||
def get_auth_headers():
|
def get_auth_headers():
|
||||||
"""Get headers with authentication token"""
|
"""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:
|
if SKIP_AUTH:
|
||||||
return {"Content-Type": "application/json"}
|
return headers
|
||||||
|
|
||||||
if AUTH_TOKEN:
|
if AUTH_TOKEN:
|
||||||
return {
|
headers["Authorization"] = f"Bearer {AUTH_TOKEN}"
|
||||||
"Authorization": f"Bearer {AUTH_TOKEN}",
|
|
||||||
"Content-Type": "application/json"
|
return headers
|
||||||
}
|
|
||||||
return {"Content-Type": "application/json"}
|
|
||||||
|
|
||||||
def get_next_device_id():
|
def get_next_device_id():
|
||||||
"""Get the next available device ID"""
|
"""Get the next available device ID"""
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ const { DataTypes } = require('sequelize');
|
|||||||
module.exports = (sequelize) => {
|
module.exports = (sequelize) => {
|
||||||
const Device = sequelize.define('Device', {
|
const Device = sequelize.define('Device', {
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.INTEGER,
|
type: DataTypes.UUID,
|
||||||
|
defaultValue: sequelize.Sequelize.UUIDV4,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
autoIncrement: true,
|
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
comment: 'Unique device identifier'
|
comment: 'Unique device identifier'
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user