2014-09-25 59 views
0

在快遞我使用:快遞/角,Passport身份驗證後,沒有進行重定向

var router = express.Router(); 
router.get('/auth/*', function (req, res, next) { 
    next(); 
}) 
app.use(router); 

app.all('/*', function(req, res) { 
    res.sendfile('index.html', { root: __dirname + '/app/dist' }); 
}); 

及其在角$ routeProvider:

when('/auth/:type', {}). 

當我使用社交登錄聚會/auth/meetup它驗證,但不會按照successRedirect Passport中指定的/profile/meetup重新路由:

app.get('/auth/meetup', passport.authenticate('meetup', { scope : 'email' })); 

app.get('/auth/meetup/callback', 
    passport.authenticate('meetup', { 
     successRedirect : '/profile/meetup', 
     failureRedirect : '/login' 
    })); 

當我點擊一個帶有href="/auth/meetup"的按鈕時,我在地址欄中顯示一個空白的網址:http://localhost:2997/auth/meetup刷新頁面時,我自動路由到'/profile/meetup',以便驗證成功。

爲什麼認證後Node/Express/Angular不會重定向到/ profile/meetup?

回答

1

您不希望angularjs將路由作爲HTML5風格的單頁應用程序路由處理。您希望瀏覽器爲/auth/meetup執行整頁加載。因此,在您的HTML <a>標記中添加target="_self"將禁用角度路由器並允許傳統的超鏈接工作。

相關問題