0

我正面临复合护照的这个问题。我已经按照指南中的步骤进行操作,但是当我尝试访问 /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)
4

1 回答 1

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

对不起我的英语不好。

于 2013-04-19T08:21:53.590 回答