Skip to content

Instantly share code, notes, and snippets.

@avastou
Created October 25, 2012 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avastou/e0c2559e148f6876d209 to your computer and use it in GitHub Desktop.
Save avastou/e0c2559e148f6876d209 to your computer and use it in GitHub Desktop.
//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