Logout on Ionic 3

Continuing the discussion from Log out doesn't work and automatically sign in:

How to perform auth0 logout (Logout) for Ionic 3+ app?

Hi @jayesh.ce,

Can you provide more details about your use case? Are you using an Auth0 user database? Social logins? Are you clearing the session and calling /logout?

Cheers,
Mark

Hi @markd,

I am using Auth0 user database. No Social logins at this stage. I am trying to clear a session by calling /logout but how can I bring the user back to my ionic app again?

Hi @jayesh.ce,

That simplifies things (no Social). Is the redirect on logout failing?

well /logout does not properly work in ionic app and even if it works, the browser with /logout call stays open and I don’t know how to redirect user back to app. redirectTo works fine for web app but for Ionic app? whats the solution? Also, new Auth0 tenants don’t have option to disable SSO. Poor thinking from Auth0. Disappointing that I chose Auth0.

Hey there @jayesh.ce, I’m sorry you are running into a issues with your Ionic app but I’m happy to help. Below I have linked our Auth0 Ionic 3 SDK quickstart guide. When you encountered your issue and looked at the doc did you feel like it could be improved in the logout section portion of the doc or any specific section? I want to gather your feedback so I can relay it to our team where we can work to reenforce our documentation with proven workflows.

Back to the subject at hand, do you mind sharing a section of your logout code that you are running into the challenge with? I have included the template’s logout function as a basic reference for contextual purposes. Thanks in advance!

  logout() {
    this.storage.remove('profile');
    this.storage.remove('access_token');
    this.storage.remove('expires_at');
    this.accessToken = null;
    this.user = null;
    this.loggedIn = false;
  }

https://auth0.com/docs/quickstart/native/ionic3/01-login

Hi Jim,

Thanks for your reply. The template logout code you have works fine to kill application session however, to logout user for auth0 session, we need to call the logout url as per the documentation here Logout

The only problem with calling logout url to log user out from auth0 (so next time user gets a login page to login) is it will open a new browser window (which will have logout url) outside the ionic app and there is no easy way to close it.

This is very inconvenient and un-professional behavior for end user.

Could you please help me with this as this is something new with auth0 as my previous tenants did not require this and now I cannot deliver app to client just because of this.

Many thanks,

Jay

@Jim.Morrison can you please guide me in the right direction?

I believe the logout functionality is missing in the auth0-cordova package that the Ionic sample relies on, but this is being addressed by the SDK team, so expect to see support for it in the upcoming Javascript native SDK very soon.
Sorry I can’t be more precise than this because I’m not in that team, but I’ll try to get a comment from them here.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.