a-crash-course-on-serverless-auth icon indicating copy to clipboard operation
a-crash-course-on-serverless-auth copied to clipboard

Callback in verifyToken

Open eduardoflorence opened this issue 5 years ago • 1 comments

In verfyToken.js i believe the correct would be: return callback('Unauthorized', null); and not: return callback(null, 'Unauthorized');

eduardoflorence avatar Oct 19 '19 16:10 eduardoflorence

The first param in the callback function is reserved for Error objects. If you want to be meticulous and pass in an Error that specifies the issue then you could do:

return callback(new Error('Unauthorized'), 'Unauthorized')

However, this will label it as an error in the 500 range. Which is not really what we'd want here. It should be a 401 error. What you could do is create a custom HTTP response and send a 401 status code response to the client. :smile:

adnanrahic avatar Dec 21 '20 08:12 adnanrahic