mikenicholson / passport-jwt

Passport authentication using JSON Web Tokens
MIT License
1.96k stars 213 forks source link

Provide error code for No auth token error #174

Open dantman opened 5 years ago

dantman commented 5 years ago

Currently when a request fails due to no JWT being present it fails using an error in the form new Error("No auth token").

If you want to allow anonymous auth there's no reasonable way to differentiate this failure from a real failure; other then the very bad practice of comparing error.message === 'No auth token'.

Please provide an err.code value for errors created by passport-jwt so they can be explicitly handled.