Fix jwt-token

This commit is contained in:
2025-09-15 06:30:17 +02:00
parent 9413d45a10
commit 2392fbd8ed
2 changed files with 8 additions and 14 deletions

View File

@@ -93,13 +93,9 @@ describe('Authentication Middleware', () => {
const user = await createTestUser({ username: 'testuser', role: 'admin' });
console.log('Created user:', user.toJSON()); // Debug log
// Get the actual string value of the UUID
const userId = user.getDataValue('id') || user.id;
console.log('User ID for JWT:', userId, typeof userId);
const token = jwt.sign(
{
userId: userId,
userId: user.id,
username: user.username,
role: user.role,
email: user.email
@@ -117,7 +113,7 @@ describe('Authentication Middleware', () => {
await authenticateToken(req, res, next);
expect(req.user).to.exist;
expect(req.user.id).to.equal(userId);
expect(req.user.id).to.equal(user.id);
expect(req.user.username).to.equal(user.username);
expect(req.user.role).to.equal(user.role);
expect(next.errors).to.have.length(0);
@@ -127,12 +123,9 @@ describe('Authentication Middleware', () => {
const tenant = await createTestTenant({ slug: 'test-tenant' });
const user = await createTestUser({ username: 'testuser', tenant_id: tenant.id });
// Get the actual string value of the UUID
const userId = user.getDataValue('id') || user.id;
const token = jwt.sign(
{
userId: userId,
userId: user.id,
username: user.username,
role: user.role,
tenantId: tenant.slug
@@ -181,12 +174,9 @@ describe('Authentication Middleware', () => {
is_active: false
});
// Get the actual string value of the UUID
const userId = user.getDataValue('id') || user.id;
const token = jwt.sign(
{
userId: userId,
userId: user.id,
username: user.username
},
process.env.JWT_SECRET || 'test-secret',