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

Adding a token named token causes all subsequent tokens to break. #265

Open
WadeDutch opened this issue Jul 27, 2022 · 3 comments
Open

Adding a token named token causes all subsequent tokens to break. #265

WadeDutch opened this issue Jul 27, 2022 · 3 comments
Labels

Comments

@WadeDutch
Copy link

WadeDutch commented Jul 27, 2022

This works just fine:

var logger = require('morgan');
logger.token('ip', function (req, res) { return req.ip ? req.ip : "" });
logger.token('uuid', function (req, res) { return (req.token ? req.token.uuid : "") });
logger.token('token', function (req, res) { return (req.token ? req.token.token : "") });

This gives "TypeError: tokens.uuid is not a function" when called in the logger:

var logger = require('morgan');
logger.token('ip', function (req, res) { return req.ip ? req.ip : "" });
logger.token('token', function (req, res) { return (req.token ? req.token.token : "") });
logger.token('uuid', function (req, res) { return (req.token ? req.token.uuid : "") });
@dougwilson
Copy link
Contributor

Ah yes, that is def a footgun. We should make it an error when trying to use a reserved word in 1.x line and also get a beta of 2.0 published which allows any token name and the other 2.0 stuff, haha.

@WadeDutch
Copy link
Author

Figured as much. Is there a list of reserved words anywhere?

@dougwilson
Copy link
Contributor

Not currently, so that is another thing to add: docs for this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants