-
-
Save avastou/e0c2559e148f6876d209 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//THIS NOT WORK | |
var oauthToken = [ | |
app.passport.authenticate(['basic', 'oauth2-client-password'], { session: false }), | |
function() { | |
//process | |
res.writeHead(200, { 'Content-Type': 'text/json' }); | |
res.json({"success":"false"}); | |
} | |
]; | |
//THIS WORK | |
var oauthToken = [ | |
function(next) { | |
var req=this.req; | |
var res=this.res; | |
app.passport.authenticate('basic', function(err, user, info) { | |
if (err) { return next(err) } | |
if (!user) { | |
res.writeHead(200, { 'Content-Type': 'text/json' }); | |
res.json({"success":"false"}); | |
} | |
console.log('ok'); | |
next(); | |
}).call(this,req,res,next); | |
return; | |
}, | |
function() { | |
//process | |
res.writeHead(200, { 'Content-Type': 'text/json' }); | |
res.json({"success":"false"}); | |
} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment