Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari does not get to message listener event and does not close the window #175

Closed
NetanelBasal opened this issue Jul 6, 2015 · 5 comments

Comments

@NetanelBasal
Copy link

I have a problem that in ios from version 8.2 and below the auth redirect does not close the window. i tried to debug this and i see that the code does not get to my console log: (i am using devise rails)

window.addEventListener("message", function(ev) {
          console.log('here');
          if (ev.data === "requestCredentials") {
            ev.source.postMessage({
              <%= yield %>
            }, '*');

            window.close();
          }
        });
@booleanbetrayal
Copy link
Collaborator

iOS Safari should have full support for postMessage API - http://caniuse.com/#search=postmessage

I probably won't have time to dive into this in the next few weeks, so please let me know if you figure out what your issue is @NetanelBasal and if it requires a bug fix.

@NetanelBasal
Copy link
Author

  return this.t = $timeout(((function(_this) {
    return function() {
       return _this.requestCredentials(authWindow);
     };
    })(this)), 500);

this script works fine in modern desktop browsers but in Ios Safari it seams like the original window setTimeout doesn't fire till it's on focus. Any work around to make the first window post message even if it's not on focus?

@NetanelBasal
Copy link
Author

I dived into this and found out that in the same iOS version (8.2) this works on chrome but in safari the bug is that only if you switch to the original window the authWindow.postMessage("requestCredentials", "*") runs and the process continues as usual.

Two comments:

  1. I think the readme should list this iOS bug so that users of ng-token-auth are aware of it.
  2. In the past I used hello.js (http://adodson.com/hello.js) and it didn't have this issue. I did not check how it's implemented, but it might give some ideas as to a workaround/different method instead of postMessage.

By the way i created the feature of "opening the auth provider in popup instead new tab" i will probably create a PR next week.

@booleanbetrayal
Copy link
Collaborator

Working on a PR where we will provide sameWindow, newWindow, and inAppBrowser implementations of OAuth sign-in flows. For now, it'll be up to the client code to decide which method is the most appropriate during ng-token-auth configuration. You can check out the branch here: https://github.com/lynndylanhurley/ng-token-auth/tree/improved_omniauth_flow

@NetanelBasal - If you would like to submit a PR (rebased against that branch perhaps) for some sort of modal popup interface instead, we'd gladly take a look. For now, going to update the docs in that branch and close this issue.

@NetanelBasal
Copy link
Author

No problem, thanks.

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

No branches or pull requests

2 participants