Fix jwt-token
This commit is contained in:
@@ -14,6 +14,16 @@ async function authenticateToken(req, res, next) {
|
||||
|
||||
try {
|
||||
const decoded = jwt.verify(token, process.env.JWT_SECRET);
|
||||
|
||||
// Log what's in the token for debugging
|
||||
console.log('🔍 JWT Token decoded:', {
|
||||
userId: decoded.userId,
|
||||
username: decoded.username,
|
||||
role: decoded.role,
|
||||
tenantId: decoded.tenantId,
|
||||
provider: decoded.provider
|
||||
});
|
||||
|
||||
const user = await User.findByPk(decoded.userId, {
|
||||
attributes: ['id', 'username', 'email', 'role', 'is_active', 'tenant_id']
|
||||
});
|
||||
@@ -30,6 +40,9 @@ async function authenticateToken(req, res, next) {
|
||||
// Extract tenant info from JWT token if available
|
||||
if (decoded.tenantId) {
|
||||
req.tenantId = decoded.tenantId;
|
||||
console.log('✅ Tenant context set:', decoded.tenantId);
|
||||
} else {
|
||||
console.log('⚠️ No tenantId in JWT token');
|
||||
}
|
||||
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user