mirror of
https://github.com/wassname/talk.git
synced 2026-06-28 17:35:42 +08:00
20 lines
383 B
JavaScript
20 lines
383 B
JavaScript
const {passport} = require('../services/passport');
|
|
|
|
const authentication = (req, res, next) => passport.authenticate('jwt', {
|
|
session: false
|
|
}, (err, user) => {
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
|
|
if (user) {
|
|
|
|
// Attach the user to the request object, now that we know it exists.
|
|
req.user = user;
|
|
}
|
|
|
|
next();
|
|
})(req, res, next);
|
|
|
|
module.exports = authentication;
|