Log out from Direct third party authentication?

Hi,

I am using the “Direct third party authentication” which works fine.
Now I need a possibility to log out so that the user ends up with the initial log in screen again.
“Navigate back” does not work for this.
Any idea?

Thanks and best,
Jo

Hi, you can use “Return to initial view” to get back to your initial view. Remember to also clear out any trace of the user that your app may hold in app variables or device storage.

1 Like

sorry for crashing this - but in my app, despite authorisation all working fine, return to initial view does nothing… Is there anything I must do to guarantee it works?

Hi @Oli_Clark , no it should work if you have an initial view configured, have once used Dismiss initial view, and then use Return to initial view to go back. :face_with_raised_eyebrow: What’s your app ID?

Hey Mari,

the id is 182676 and the log out button is on the LandingPageSas page.

it would be great if you could take a look

Oli

Since you have authentication working fine, have you used a “Delete item from storage” logic component to clear your app variables? I noticed Mary didn’t actually mention that it was a critical component you could download from the Marketplace. When I started here, I wouldn’t have known that it was even there. :sweat_smile:

If you have a logout button, this is what your logic flow should look like:

persistedUser is the key we use for Backendless, but I’m not sure if it would be different for other backends. If it’s the same, try that. :slight_smile:

Thanks for that - currently the app doesn’t save anything to storage (that’s going to change), so at the moment that shouldn’t apply right?

The Button sends a log out request to the backend (sashido - i migrated from backendless because I couldn’t afford the monthly charges!) which terminates the session - and that works - but it then just sits on the same page with no data being able to load because the session key is no longer valid.

Oli

I checked the app, and on the Log in page, you check if there is a session token, if there is then it dismisses the initial view - and I noticed that you never clear the token. So you one thing you could test to verify that this is actually the issue, you could remove the dismissal from the log in page.

Thanks! :slightly_smiling_face:

1 Like

Hmm, given that I’m used to doing it the Backendless way where it’s app variables temporarily hosting the critical auth data, I’ll admit I’m stumped here. I do think you would use app variables one way or another to store the data for the current user session. So even if it connects to your backend to log out the user, you would still need to clear those variables. :thinking:

Hey Kristian - you are a genius - that was the issue…

THANK YOU SO MUCH.

Oli

1 Like

Kristian solved it - on my login page i was checking to see if a session token appvariable existed (without checking if it was valid!!!) - and because I’d not deleted the session token on log out - it was just bouncing me back to a page i had no right to be at!!!

2 Likes

Aye, there you have it! That cool moment when “It just works™”. :slight_smile:

Take care, mate.

1 Like