0

In Express I'm using:

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

And in Angular $routeProvider:

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

When I use social login to Meetup /auth/meetup it authenticates but doesn't reroute to /profile/meetup as specified in the successRedirect Passport:

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

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

When I click a button with href="/auth/meetup"I get a blank screen with the url in the address bar: http://localhost:2997/auth/meetup when I refresh the page, I am automatically routed to '/profile/meetup'so the authentication was successful.

Why isn't Node/Express/Angular not redirecting to /profile/meetup after authentication?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
alyx
  • 2,593
  • 6
  • 39
  • 64

1 Answers1

1

You don't want angularjs to handle the route as an HTML5 style single page app route. You want the browser to do a full page load for /auth/meetup. So in your HTML <a> tag add target="_self" which will disable the angular router and allow a traditional hyperlink to work.

Peter Lyons
  • 142,938
  • 30
  • 279
  • 274