ThexXTURBOXx / flutter_web_auth_2

Flutter plugin for authenticating a user with a web service
https://pub.dev/packages/flutter_web_auth_2
MIT License
51 stars 50 forks source link

added fallback for window.opener being null #58

Closed poster983 closed 1 year ago

poster983 commented 1 year ago

Fixes #44

Implements a secondary method of relaying the callback url to flutter by using local storage.

The new auth.html javascript would look like this.

    if(window.opener) {
        window.opener.postMessage({
        'flutter-web-auth-2': window.location.href
        }, window.location.origin);
    } else {
        //if window.opener is null, we fallback to the local storage approach.
        localStorage.setItem('flutter-web-auth-2', window.location.href);
    }
   window.close();
ThexXTURBOXx commented 1 year ago

Thanks for the PR! Will review, merge and publish as soon as I am back from my vacation (probably in 3-7 days)