mirror of
https://github.com/wassname/talk.git
synced 2026-08-15 12:55:10 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,25 +1,29 @@
|
||||
const {passport} = require('../services/passport');
|
||||
const { passport } = require('../services/passport');
|
||||
const debug = require('debug')('talk:middleware:authentication');
|
||||
|
||||
const authentication = (req, res, next) => passport.authenticate('jwt', {
|
||||
session: false
|
||||
}, (err, user) => {
|
||||
if (err) {
|
||||
debug(`cannot get the user: ${err}`);
|
||||
return next(err);
|
||||
}
|
||||
const authentication = (req, res, next) =>
|
||||
passport.authenticate(
|
||||
'jwt',
|
||||
{
|
||||
session: false,
|
||||
},
|
||||
(err, user) => {
|
||||
if (err) {
|
||||
debug(`cannot get the user: ${err}`);
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (user) {
|
||||
if (user) {
|
||||
debug('user was on request');
|
||||
|
||||
debug('user was on request');
|
||||
// Attach the user to the request object, now that we know it exists.
|
||||
req.user = user;
|
||||
} else {
|
||||
debug('user was not on request');
|
||||
}
|
||||
|
||||
// Attach the user to the request object, now that we know it exists.
|
||||
req.user = user;
|
||||
} else {
|
||||
debug('user was not on request');
|
||||
}
|
||||
|
||||
next();
|
||||
})(req, res, next);
|
||||
next();
|
||||
}
|
||||
)(req, res, next);
|
||||
|
||||
module.exports = authentication;
|
||||
|
||||
Reference in New Issue
Block a user