Angularjs 快速/角度,在Passport身份验证后不重定向
在Express中,我使用:Angularjs 快速/角度,在Passport身份验证后不重定向,angularjs,node.js,express,passport.js,meetup,Angularjs,Node.js,Express,Passport.js,Meetup,在Express中,我使用: 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中:
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', {}).
当我使用社交登录到Meetup/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”
单击按钮时,我会看到一个空白屏幕,地址栏中有url:http://localhost:2997/auth/meetup
刷新页面时,我会自动路由到“/profile/meetup”
,因此身份验证成功
为什么Node/Express/Angular在身份验证后不重定向到/profile/meetup?您不希望angularjs将路由处理为HTML5风格的单页应用程序路由。您希望浏览器为
/auth/meetup
执行完整的页面加载。因此,在HTML
标记中添加target=“\u self”
,这将禁用角度路由器并允许传统超链接工作