Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

google authentication callback url bug #535

Closed
junit38 opened this issue Apr 27, 2015 · 8 comments · Fixed by #568
Closed

google authentication callback url bug #535

junit38 opened this issue Apr 27, 2015 · 8 comments · Fixed by #568

Comments

@junit38
Copy link

junit38 commented Apr 27, 2015

Hi,
I get URL like localhost:3000/# when I use google authentication with passport.

I fixed the problem using the same way which has been used to fix the Facebook bug with redirect (public/modules/application.js):

//Then define the init function for starting up the application
angular.element(document).ready(function() {
    // Fixing facebook bug with redirect
    if (window.location.hash === '#_=_') window.location.hash = '#!';

    // Then init the app
    angular.bootstrap(document, [ApplicationConfiguration.applicationModuleName]);
});

I added this part:

// Fixing google bug with redirect
    if (window.location.href[window.location.href.length - 1] === '#' &&
        // for just the error url (origin + /#)
        (window.location.href.length - window.location.origin.length) === 2) {
        window.location.href = window.location.origin + '/#!';
    }

Does you know something about it?

Thanks.

@ilanbiala
Copy link
Member

Are you missing some code there? Maybe an if and another closing brace?

@junit38
Copy link
Author

junit38 commented Apr 28, 2015

I added this code into the first function, the whole become:

//Then define the init function for starting up the application
angular.element(document).ready(function() {
    // Fixing facebook bug with redirect
    if (window.location.hash === '#_=_') window.location.hash = '#!';

    // Fixing google bug with redirect
    if (window.location.href[window.location.href.length - 1] === '#' &&
        // for just the error url (origin + /#)
        (window.location.href.length - window.location.origin.length) === 2) {
        window.location.href = window.location.origin + '/#!';
    }

    // Then init the app
    angular.bootstrap(document, [ApplicationConfiguration.applicationModuleName]);
});

@ppotoplyak
Copy link

ditto, started hitting the same issue recently.

Here is the workaround that I am running with:

// Then define the init function for starting up the application
angular.element(document).ready(function() {
  if (window.location.hash === '#_=_') {
    //Fixing facebook bug with redirect
    window.location.hash = '#!';
  } else if(window.location.hash.length === 0) {
    // Without this, after G+ auth we started taking:
    // Uncaught Error: [$location:ihshprfx] Invalid url "https://streetspin.com/#", missing hash prefix "#!"
    // needs to be root caused at some point
    window.location.hash = '#!/';
  }

  //Then init the app
  angular.bootstrap(document, [ApplicationConfiguration.applicationModuleName]);
});

I was not sure if this was a self imposed regression or something outside of our control.

@ppotoplyak
Copy link

Just checked tip and the issue is still there but it seems browser dependent.

No problems using Firefox:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0

Issue is there with Chrome:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36

Chrome taking this error:
angular.js:78 Uncaught Error: [$location:ihshprfx] Invalid url "http://localhost:3000/#", missing hash prefix "#!".
http://errors.angularjs.org/1.2.28/$location/ihshprfx?p0=http%3A%2F%2Flocalhost%3A3000%2F%23&p1=%23!

@ppotoplyak
Copy link

Wiresharking reveals that indeed a # is being appended to the callback URL but only when using Chrome.

This should probably be bumped up to a P1 priority as Chrome G+ auth is not functioning properly without a workaround. junit38's workaround is probably the more elegant as it specifically addresses this issue.

@junit38 , let me know if you would like to submit a PR, otherwise I can put one together.

The real question is why is Google appending the # with no error code to follow, please upvote if you agree:
http://stackoverflow.com/questions/30010046/added-to-google-oauth-2-0-callback-url/

thanks

@junit38
Copy link
Author

junit38 commented May 5, 2015

@ppotoplyak I'm ok to submit a PR let me know how to proceed and when I can do it.

Should I need to create my branch of the project ?

Thanks

@ppotoplyak
Copy link

@junit38 lets get guidance from ilanbiala as he would be the approving authority.

@ilanbiala we would like to make sure that you agree that this is a real issue and a PR for a workaround is required?

thanks

@floydpink
Copy link
Contributor

Thank you @junit38 and @ppotoplyak - have submitted a PR with the fix from @junit38

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants