Skip to content

Commit 5dc9cb4

Browse files
committed
Use correct http status code with JsonWebTokenError
1 parent a566a49 commit 5dc9cb4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/content/4/fi/osa4d.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ const errorHandler = (error, request, response, next) => {
201201
} else if (error.name === 'MongoServerError' && error.message.includes('E11000 duplicate key error')) {
202202
return response.status(400).json({ error: 'expected `username` to be unique' })
203203
} else if (error.name === 'JsonWebTokenError') { // highlight-line
204-
return response.status(400).json({ error: 'token missing or invalid' }) // highlight-line
204+
return response.status(401).json({ error: 'token missing or invalid' }) // highlight-line
205205
}
206206

207207
next(error)

0 commit comments

Comments
 (0)