Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using node-jsonwebtoken error message ? #98

Closed
jinwyp opened this issue Apr 27, 2017 · 4 comments
Closed

Using node-jsonwebtoken error message ? #98

jinwyp opened this issue Apr 27, 2017 · 4 comments

Comments

@jinwyp
Copy link

jinwyp commented Apr 27, 2017

Suggestion for using node-jsonwebtoken module error message

see https://github.com/auth0/node-jsonwebtoken errors:
TokenExpiredError and JsonWebTokenError

change file index.js line 51

 if (!passthrough) {
                const msg = debug ? e.message : 'Authentication Error';
                ctx.throw(401, msg);
            }

change to

 if (!passthrough) {
                const msg = debug ? e.message : e.message || 'Authentication Error';
                ctx.throw(401, msg {name : e.name || 'UnauthorizedError'});
            }
@olegmdev
Copy link

+1

@sdd
Copy link
Collaborator

sdd commented May 23, 2017

Hi,

Sorry for the delayed reply, I've been on holiday. What is the motivation behind this? You can set opts.debug to true to get the original e.message as the thrown error message. I'm potentially open to this if you can provide good enough reasons why this would be useful enough to potentially risk breaking anyone's apps who depend on those messages being what they are now.

@clintmod
Copy link
Contributor

clintmod commented Sep 8, 2017

It seems a bit unusual to have to pass a debug flag to learn that the token has expired. It also seems pretty important to know that the token has expired so that the api consumer can refresh it.

@sdd
Copy link
Collaborator

sdd commented Aug 29, 2018

I agree - it is unusual. But still, if the problem can be solved by using option.debug = true, then changing the behaviour to make it less unusual would affect more people than just requiring users who need the message to set options.debug to true.

@sdd sdd closed this as completed Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants