1

I'm trying to include oauth for some third party applications in my app. Basically on a button click I request for the url for auth from the backend. Then I open a new window using window.open(url). After the user completes the process, my popup is redirected to the callback url.

Now I want to close the popup as soon as I'm redirected to the popup url. How do I do that?

function connectToApp() {
    loginRequest()
        .then(function openNewWindow(res) {
            var url = res.data,
                width = 700,
                height = 500,
                left = (screen.width/2) - (width / 2),
                top = (screen.height/2) - (height / 2),
                params = 'modal=yes, alwaysRaised=yes, left=' + left + ', top=' + top + ', width=' + width + ', height=' + height;

            if(newWindow === null || newWindow.closed) {
                newWindow= window.open(url, 'newWindow', params);
                newWindow.focus();
            } else {
                newWindow.focus();
            }                   
    })
};

Once I complete the authentication, I'm redirected to callback url to my new window. I tried using window.postMessage but couldn't figure out how to implement that.

  1. I want to close the new window.
  2. How would my app know that the user has completed the authentication?
  3. I do not need to redirect to callback url as I just want to toggle the view in my app from logged out to logged in once the authentication is complete.
georgeawg
  • 48,608
  • 13
  • 72
  • 95
LeDerp
  • 21
  • 3

0 Answers0