passport-http-bearer
passport-http-bearer copied to clipboard
Stops callback from running
I have a post that runs that simply logs out a phrase and whenever the passport.authenticate is authenticating the route, the callback never runs even though authentication passes.
What debugging have you done to isolate this issue to this project?
I took out all the content and made the callback directly in the route with a only a console log saying it fired. I sent it with and without an access token. Without it, it did come back unauthorized, but with it nothing fired. After I took it out, it all worked. I don't necessarily need it because there will be a passport local authorization that I'm using for changing someone's password, but that is beside the point. I've never had this problem before and it works on every other route I have it on, but for some reason this one was different (and it's not really any different).
I don't understand what you mean by "took out all the content"? Content in the request, or content in the code?
It might help to post an example of the code that is a simple way to reproduce the issue
Sent from my iPhone
On Aug 13, 2015, at 7:00 AM, Steven Wade [email protected] wrote:
I took out all the content and made the callback directly in the route with a only a console log saying it fired. I sent it with and without an access token. Without it, it did come back unauthorized, but with it nothing fired. After I took it out, it all worked. I don't necessarily need it because there will be a passport local authorization that I'm using for changing someone's password, but that is beside the point. I've never had this problem before and it works on every other route I have it on, but for some reason this one was different (and it's not really any different).
— Reply to this email directly or view it on GitHub.
Works:
app.post('/api/v1/user/changePassword', function(req, res) {console.log('firing'});
Doesn't work:
app.post('/api/v1/user/changePassword', passport.authenticate('bearer', {session: false}), function(req, res) {console.log('firing'});
^ that code will send back an Unauthorized code if the token is not present, but when it is, it doesn't fire the callback.
Is your verify callback getting called? Are you calling 'done' within that. I'd suspect not, and that is the cause
Sent from my iPhone
On Aug 14, 2015, at 7:13 AM, Steven Wade [email protected] wrote:
Works: app.post('/api/v1/user/changePassword', function(req, res) {console.log('firing'});
Doesn't work: app.post('/api/v1/user/changePassword', passport.authenticate('bearer', {session: false}), function(req, res) {console.log('firing'});
^ that code will give send back an Unauthorized if the token is not present, but when it is, it doesn't fire the callback.
— Reply to this email directly or view it on GitHub.
One more reason to promisifyAll. ;-)