0

Seems like other people have had similar issues, but the opposite direction... So trying to set up google authentication, and set up a call to passport on "/auth/google"

   app.get('/auth/google', passport.authenticate('google', { scope : ['profile', 'email'] }));

    // the callback after google has authenticated the user
    app.get('/auth/google/callback',
        passport.authenticate('google', {
            successRedirect : '/internal',
            failureRedirect : '/login',
            failureFlash : true
        }));

That works, if I go to 127.0.0.1/auth/google I get google login.

I then created a button to ask to be logged in

<a href="/auth/google"><button type="button" class="btn btn-default btn-lg">
    <span class="glyphicon glyphicon-star" aria-hidden="true"></span> Login (Admin)
</button></a>

That button does send you to 127.0.0.1/auth/google, which the ngrouter takes as otherwise (.otherwise({ redirectTo: "/" });)

And this is where my problem seems to be. Direct call to the server and it works, however, if I call it via angular, the router picks it up. So how do I force "angular" to ask the server for the page?

The auth set all is defined as app.get (as per the above example). I am not certain if this is because I am not defining these as express routes, they are under a module.export instead. In which case, is there a way to just tell express to pick these up and forward them internally or similar.

vrghost
  • 1,084
  • 2
  • 19
  • 42

1 Answers1

0

Someone else had figured it out.

AngularJS HTML5 Routing Enabled : Passing URL Back to server?

I figured it out! :) The solution is to add target='_self' to your anchor tag. Any of the other target values work too; "_blank", "_top" and so on. I tested this in IE 9, 10; Chrome 40-43, Opera 25-29, and Safari 5.1

Community
  • 1
  • 1
vrghost
  • 1,084
  • 2
  • 19
  • 42