We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
/:id
I've ran into a problem that works on a "regular" route ('/') but not on one at /:id.
'/'
passport.authenticate('bearer', { session: false }, function(err, user, info) { if (user) // check user's role for premium or not if (user.role == "premium" || user.role == "editor" || user.role == "moderator" || user.role == "admin") return ArticleModel.find(function (err, articles) { return res.send(articles); }); else return ArticleModel.find(function (err, articles) { var response = articles.filter(stripOutPremium); return res.send(response); }); else // return items even if no authentication is present return ArticleModel.find(function (err, articles) { var response = articles.filter(stripOutPremium); return res.send(response); }); })(req, res, next);
Will just sit and spin forever, I get no response. I can't get the passport.authenticate('bearer'... function to run at all.
passport.authenticate('bearer'...
Any idea why something like this works on a simple route like app.get('/') and not app.get('/:id')?
app.get('/')
app.get('/:id')
The text was updated successfully, but these errors were encountered:
This must have been a fluke, I'm not having a problem at all, please close...
router.get('/:id', function(req, res, next) { passport.authenticate('bearer', { session: false }, function(err, user, info) { if (user) // check user's role for premium or not if (user.role == "premium" || user.role == "editor" || user.role == "moderator" || user.role == "admin") return ArticleModel.findById(req.params.id, function (err, article) { return res.send(article); }); else return ArticleModel.findById(req.params.id, function (err, article) { return res.send('truncated article'); }); else // return items even if no authentication is present return ArticleModel.findById(req.params.id, function (err, article) { return res.send('truncated article'); }); })(req, res, next); });
Sorry, something went wrong.
No branches or pull requests
I've ran into a problem that works on a "regular" route (
'/'
) but not on one at/:id
.passport.authenticate('bearer', { session: false }, function(err, user, info) {
if (user)
// check user's role for premium or not
if (user.role == "premium" || user.role == "editor" || user.role == "moderator" || user.role == "admin")
return ArticleModel.find(function (err, articles) {
return res.send(articles);
});
else
return ArticleModel.find(function (err, articles) {
var response = articles.filter(stripOutPremium);
return res.send(response);
});
else
// return items even if no authentication is present
return ArticleModel.find(function (err, articles) {
var response = articles.filter(stripOutPremium);
return res.send(response);
});
})(req, res, next);
Will just sit and spin forever, I get no response. I can't get the
passport.authenticate('bearer'...
function to run at all.Any idea why something like this works on a simple route like
app.get('/')
and notapp.get('/:id')
?The text was updated successfully, but these errors were encountered: