Fix jwt-token
This commit is contained in:
@@ -71,9 +71,9 @@ async function authenticateToken(req, res, next) {
|
||||
next();
|
||||
} catch (error) {
|
||||
console.error('Token verification error:', error);
|
||||
return res.status(403).json({
|
||||
return res.status(401).json({
|
||||
success: false,
|
||||
message: 'Invalid or expired token'
|
||||
message: 'Invalid token'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ describe('Authentication Middleware', () => {
|
||||
|
||||
it('should accept valid JWT token and set user data', async () => {
|
||||
const user = await createTestUser({ username: 'testuser', role: 'admin' });
|
||||
console.log('Created user:', user.toJSON()); // Debug log
|
||||
|
||||
const token = jwt.sign(
|
||||
{
|
||||
userId: user.id,
|
||||
|
||||
Reference in New Issue
Block a user