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

Detect when user cancels authentication #25

Closed
michaeltintiuc opened this issue Feb 28, 2019 · 3 comments
Closed

Detect when user cancels authentication #25

michaeltintiuc opened this issue Feb 28, 2019 · 3 comments
Labels
enhancement New feature or request web
Milestone

Comments

@michaeltintiuc
Copy link

michaeltintiuc commented Feb 28, 2019

It is possible for the user to close the popup window and not authenticate, this results in a failed login attempt without any means to catch it.

The workaround that I have found is to set an interval and watch the windowHandle.close of OAuth2Client class, but this property is not public meaning that in TypeScript I have to extend the interface.

It's quite a bit of extra work and could easily be part of the source.

@moberwasserlechner
Copy link
Collaborator

moberwasserlechner commented Feb 28, 2019

Could you share your code in a PR please?

@moberwasserlechner moberwasserlechner added enhancement New feature or request web labels Feb 28, 2019
@michaeltintiuc
Copy link
Author

Note that I have to do 2 things to make it work with TypeScript properly:

  1. Plugins.OAuth2Client is declared option, thus I get warning that OAuth2Client could be udnefined
  2. Plugins.OAuth2Client as any so that I could silence the warning of windowHandle not existing
          const timer = setInterval(function() {
            if ((Plugins!.OAuth2Client as any).windowHandle.closed) {
              clearInterval(timer);
              handleAuthError();
            }
          }, 500);

          const authResult = await Plugins!.OAuth2Client!.authenticate(data);

@moberwasserlechner moberwasserlechner modified the milestones: beta2, beta3 Feb 28, 2019
@moberwasserlechner moberwasserlechner removed this from the beta5 milestone Jun 22, 2019
@moberwasserlechner moberwasserlechner added this to the 1.1.0 milestone Jan 21, 2020
@moberwasserlechner
Copy link
Collaborator

If the user cancels the login process by closing the windows the error code "USER_CANCELLED" will be returned.

This functionality and error is already present for iOS and Android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request web
Projects
None yet
Development

No branches or pull requests

2 participants