passport-http-bearer icon indicating copy to clipboard operation
passport-http-bearer copied to clipboard

Stops callback from running

Open suederade opened this issue 10 years ago • 6 comments

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.

suederade avatar Aug 12 '15 17:08 suederade

What debugging have you done to isolate this issue to this project?

jaredhanson avatar Aug 13 '15 01:08 jaredhanson

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).

suederade avatar Aug 13 '15 14:08 suederade

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.

jaredhanson avatar Aug 13 '15 14:08 jaredhanson

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.

suederade avatar Aug 14 '15 14:08 suederade

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.

jaredhanson avatar Aug 14 '15 14:08 jaredhanson

One more reason to promisifyAll. ;-)

mk-pmb avatar Aug 14 '15 20:08 mk-pmb