CompoundJS和护照支持

时间:2013-03-04 11:22:18

标签: javascript node.js oauth passport.js compoundjs

我用复合护照面对这个问题。我已经按照指南中的步骤进行了操作,但是当我尝试访问/ auth / github时,我无法正常工作。

任何提示?

GET /auth/github controller: auth action: github
Params: {"controller":"auth","action":"github"}
>>>  perform github
Error: Undefined action auth#github(/auth/github)
at Object.FlowControl.call.context.innerNext (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:67:27)
at Array.FlowControl.call.collection.forEach.queue.push.ctl.context.inAction [as 1] (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:139:28)
at run (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:102:27)
at Array.FlowControl.call.action [as 0] (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:60:13)
at run (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:102:27)
at FlowControl.call.compiledAction.(anonymous function) (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:90:9)
at Controller.call (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:49:16)
at Controller.call (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:93:10)
at Controller.perform (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/node_modules/kontroller/lib/flow-control.js:18:10)
at ControllerBrigde.callControllerAction (/Users/javiermanzanomorilla/Development/workspace/authapp/node_modules/compound/lib/controller-bridge.js:95:9)

1 个答案:

答案 0 :(得分:0)

我认为你没有申请护照。

如果您使用的是复合护照,则必须通过调用config / environment中的init函数对其进行初始化。

    var pass_connect=require('compound-passport');
     app.configure(function(){
     ....

   //init the compound passport
    pass_connect.init(compound);

    app.use(app.router);
 });

如果您想要手动初始化它,则必须调用这两种方法:

 var passport=require('passport');    
 var Strategy = require('passport-github').Strategy;
    passport.use(new Strategy({
    clientID: conf.github.clientID,
    clientSecret: conf.github.secret,
    callbackURL: conf.baseURL + 'auth/github/callback'
}, exports.callback));

app.get('/auth/github',
    passport.authenticate('github'));
app.get('/auth/github/callback',
    passport.authenticate('github', { failureRedirect: '/' }),
    exports.redirectOnSuccess);
抱歉我的英语。