From a38b44306546af56f666add49842fedc25cb35e1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 22 Jul 2020 23:40:51 -0700 Subject: conduct internal swap --- lib/passport.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/passport.js b/lib/passport.js index 1d80d9b8..8f87d42d 100644 --- a/lib/passport.js +++ b/lib/passport.js @@ -28,4 +28,12 @@ passport = Passport.use( ); auth = passport.authenticate("jwt", { session: false }); + +optionalAuth = function (req, res, next) { + passport.authenticate("jwt", { session: false }, function (err, user, info) { + req.user = user; + next(); + })(req, res, next); +}; + app.use(passport.initialize()); -- cgit v1.2.3