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

Bearer is removing attributes from req.body #44

Open
igordeoliveirasa opened this issue Feb 7, 2016 · 1 comment
Open

Bearer is removing attributes from req.body #44

igordeoliveirasa opened this issue Feb 7, 2016 · 1 comment

Comments

@igordeoliveirasa
Copy link

The 'description' attribute is always absent/undefined, even explicitly passing it.
Just because I'm using passport.authenticate('bearer.... If I remove, it comes.

route.post('/', passport.authenticate('bearer', {session: false}), function(req, res, next){
var name = req.body.name;
var description = req.body.description;
console.log("description:", description);
if (!name || name.trim() == '') {
res.status(400).json({message:"É necessário informar o nome do papel."});
}
else if (!description || description.trim() == '') {
res.status(400).json({message:"É necessário informar a descrição do papel."});
}
else {
var role = new Role({name:name, description: description, user:req.user});
role.save().then(function(role){
res.json(role);
},next);
}
});

@igordeoliveirasa
Copy link
Author

Here is the Bearer configuration:

passport.use(new BearerStrategy(
function(token, done) {
jwt.verify(token, secretTokenKey, null, function(err, verifiedToken){
if (err) {
return done(err);
}
else {
User.findOne({username:verifiedToken._doc.username}).then(function(user){
return done(null, user);
}, function(err){
return done(err);
});
}
});
}
));

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