2013-06-27 59 views
3

我的應用程序是使用express的nodejs web應用程序。它用作cms和api的投資組合網站。護照身份驗證在Heroku上不起作用?

在我登錄路由我有以下代碼:

passport.authenticate('local', function(err, user, info){ 
    if(err){ 
     return next(err); 
    } else if(!user){ 
     res.format({ 
      json: function(){ 
       return error.throw403(req, res, next); 
      }, 
      html: function(){ 
       return res.redirect('/login'); 
      } 
     }); 
    } else { 
     console.log('login route, user'); 
     console.log(user); 
     req.logIn(user, function(err){ 
      if(err){ 
       return next(err); 
      } else { 
       res.format({ 
        json: function(){ 
         return res.send(user); 
        }, 
        html: function(){ 
         return res.redirect('/cms/users'); 
        } 
       }); 
      } 
     }); 
    } 
})(req, res, next); 

我的Heroku的日誌告訴我,用戶定義和正確的。該req.logIn()發射,成功,並重定向(應該)到/cms/users。但是,由於req.user不在請求中,因此我在/cms/users處得到403。這讓我覺得我的會議不會持久,但我不是專家,也不知道下一步該做什麼。

我使用的是redistogo和mongolab,並且這兩個配置都是使用CLI設置的。有什麼建議麼?我卡住了!謝謝。

編輯:我應該補充一切工作正常在我的本地機器上。

+0

我明白了,閱讀heroku上的redistogo文檔,並不斷調整我的配置順序,直到它工作。 – reagan

回答