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

Lock not shown after logout #24

Open
bujardeari opened this issue Jun 8, 2017 · 1 comment
Open

Lock not shown after logout #24

bujardeari opened this issue Jun 8, 2017 · 1 comment

Comments

@bujardeari
Copy link

When i hit the logout button, the user logs out, but when i try to login again, i would like the lock to be shown first , not to directly logg in with the last logged in user.
When i manually go and clean history on Chrome (Android), and then try to login on my app again, then it shows up the lock.
This may not be an issue, but maybe someone can help me how to achieve what i want?

@gusmao
Copy link

gusmao commented Jun 29, 2017

Hi @bujardeari !
I was suffering from the same. As we see, we got no replies from developers yet - unfortunately.

I had to go into Auth0Cordova sources to find an alternative.

I implemented a logout method in index.js.

The only thing it does is to call the browser/safarariwebview agent to redirect to Auth0 logout URL...

Something like:

CordovaAuth.prototype.logout = function (parameters, callback) {
  if (!callback || typeof callback !== 'function') {
    throw new Error('callback not specified or is not a function');
  }

  var self = this;

  getAgent(function (err, agent) {
    if (err) {
      return callback(err);
    }

    
    var returnTo = encodeURIComponent('YOUR_SCHEME://YOUR_SCHEME/cordova/YOUR_SCHEME/callback');
    agent.open('https://YOUR_DOMAIN.auth0.com/v2/logout?client_id=YOUR_CLIENT_ID&returnTo='+returnTo, function (error, result) {
      if (error != null) {
        session.clean();
        return callback(error);
      }

      if (result.event === 'closed' && getOS() === 'ios') {
        session.clean();
        return callback(new Error('user canceled'));
      }

      if (result.event !== 'loaded') {
        // Ignore any other events.
        return;
      }

      agent.close();

      callback(null,{status:'ok'})
    });
  });
};

It works on both Android an iOS.

In Android we still have a drawback. The agent.close() line don't actually make the chrome browser to close. I think there is a bug in SafariWebView (https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller) open for this w/o correction prevision. I'll dig it later.

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