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

Popup is not closing #134

Open
Dnomyar opened this issue Dec 14, 2017 · 11 comments
Open

Popup is not closing #134

Dnomyar opened this issue Dec 14, 2017 · 11 comments

Comments

@Dnomyar
Copy link

Dnomyar commented Dec 14, 2017

Hi there,

I have an issue when I use the authenticate('google') of AuthService.

When I trigger the button, the popup opens. Then, I connect my google accout and I am redirected to my server. Finally, I get a 200 from my server. But the popup doesn't closes itself.

Note : If I manually close the window, I get the error : Authentication Canceled.

What are the conditions for the popup to close itself ?

Here is the code :

this.auth.authenticate('google')
      .subscribe({
        next: (response) => console.log('response', response),
        error: (err: any) => {
            console.log('Err', err)
            this.eh.handleError(err)
        }, complete: () => {
            console.log('complete')
            this.router.navigateByUrl('dashboard')
        }
      });

I guess that the solution is here : https://github.com/ronzeidman/ng2-ui-auth/blob/master/src/popup.service.ts#L89
It seems to me that, in order that the popup closes itself, the configured redirect URI have to be the same that the location of the window. Am I right ?

Thanks for your work

@ronzeidman
Copy link
Owner

Yes, your redirect URI should equal the configured redirect URI (or the origin uri if you've not configured it in the provider)

@ronzeidman
Copy link
Owner

another common issue is that you have a redirect that does not preserve the query params and then the code cannot catch the query params on time. you'll have to use a non-redirected redirect in order for the popup to close.

@Dnomyar
Copy link
Author

Dnomyar commented Dec 29, 2017

Thanks for your anwsers (I will have a look later)

@ronzeidman
Copy link
Owner

Any developments on this issue?

@Dnomyar
Copy link
Author

Dnomyar commented Jan 26, 2018

Not yet and not soon, sorry :/

@FedeDR
Copy link

FedeDR commented Mar 13, 2018

Hi
I have the same issue
in the 7.0.2 version, I have this configuration
{ baseUrl: 'http://domain.com/api/v1/social_auth' providers: { clientId: 'XXXXXXX, url: 'facebook', scope: ['email', 'public_profile'], redirectUri: 'http://domain.com', } }
with both provider url configured (url and redirectUri) I saw this behavior:
The authenticate open the popup and when I log in with Facebook credentials the redirect make a POST on my server (baseUrl + url) to exchange the token. After that, we redirect to redirectUri, than the popup close automatically and the response of exchange server was caught by authenticate's function that finalizes the login

In the 8.0.1 version, if I don't set the redirectUri, I have the same behavior as the previous version, but the post params brake the compatibility with the server.
If the redirectUri is set we don't have any POST to my server for token exchange and the popup do not automatically close
now, I can resolve this issue in two ways:
Change POST payload to old payload version
catch the code on redirect url, and exchange token manually. But how can I pass the response to the authenticate subscription?

@tuhin24
Copy link

tuhin24 commented May 5, 2018

I am not getting popup page. Instead I am getting a new page instead when I do
this.authService.authenticate(type).subscribe({
error: (err) => alert('An error occurred while authentication.')
, complete: () => alert('Authentication successfull')
});

Any tip on how I can get the page to show as a popup?

@ronzeidman
Copy link
Owner

@tuhin24 what's your environment? what configuration you use? what is the "type"?

@KAMAELUA
Copy link

KAMAELUA commented Jul 3, 2018

Popup doesn't close on Edge.

Angular 6.
"ng2-ui-auth": "^9.0.0-beta.2",

@ronzeidman
Copy link
Owner

Just tested it, works for me.
There are timing issues in some angular apps that redirect the "redirect url" automatically to anther url causing this issue. try using a blank page that doesn't redirect anywhere as the redirect url either from the server or from the angular app itself.

@omostepaniuk
Copy link

omostepaniuk commented Dec 5, 2019

Just tested it, works for me.

What version of the Edge have you tried it with?

It works on Windows Edge <44 without any issues. However, it does fail on Edge 44 for me as well. Looks like Edge throws

ERROR Error: Permission denied

here

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

6 participants