2014-09-25 62 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"将禁用角度路由器并允许传统的超链接工作。

相关问题