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

authenticate callback function parameters #212

Open
gkatsanos opened this issue May 30, 2020 · 0 comments
Open

authenticate callback function parameters #212

gkatsanos opened this issue May 30, 2020 · 0 comments

Comments

@gkatsanos
Copy link

I was wondering if the following is correct:
router.get(validate.authorization, authorize(), controller.list);

const handleJWT = (req, res, next) => async (err, user, info) => {
  const error = err || info;

  if (err || !user) {
    Boom.boomify(error, { statusCode: 401, stack: err ? err.stack : 'null' });
    return next(error);
  }

  req.user = user;

  return next();
};

exports.authorize = () => (req, res, next) =>
  passport.authenticate("jwt", { session: false }, handleJWT(req, res, next))(
    req,
    res,
    next
  );

It seems the handleJWT is not getting all parameters under some scenarios and by reading at the documentation wasn't sure if what I'm doing is correct.

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

1 participant