Auth0 Home Blog Docs

Logout on Ionic 3

ionic
logout
auth0
ionic-3
#1

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

How to perform auth0 logout (https://auth0.com/docs/logout) for Ionic 3+ app?

#2

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

#3

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?

#4

Hi @jayesh.ce,

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

#5

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.

#7

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;
  }
#8

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 https://auth0.com/docs/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

#9

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

#10

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
closed #11

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