46
Views
8
Comments
I do logout but it always end up logging in again

Hi guys, this time i bring you an authentication problem. I have this logout flow that works fine in web emulation. 


logout flow:

DoLogout:Action used to make the user logout (Outystems and azure)

Logs out a specific user from the application.

assign the url that comes from the DoLogout_DS


For some reason, when i get redirected to the login page after logging out (should have the form so i can populate username and password), the application always log me back in.

I think it might be because of the web view that is opened to log in for the first time, since when i close app and reopen it the session expires. How can i handle this?

2026-03-20 01-28-51
Saugat Biswas

Hi @João Espinheira,

I suspect your logout flow only logs the user out of OutSystems, but does NOT log them out of Azure AD. 

So this is what happens: 

  • User logs in the first time via Azure AD 
  • Azure AD creates an SSO session cookie 
  • User taps “Logout” 
  • You call: 
    • DoLogout_DS 
    • OutSystems session ends
  • App redirects to Login page 
  • Login page immediately redirects to Azure AD 
  • Azure AD reuses the existing SSO session 
  • User is logged in again automatically

Closing & reopening the app “fixes” it because the WebView session/cookies are destroyed, which confirms the above flow.

So basic rule is: 

Logging out of OutSystems is not equal to logging out of Azure AD. You must explicitly log out of both.

Solution:

Step 1: Log out of OutSystems (keep this). This part is correct.

Step 2: Log out of Azure AD explicitly (This is the fix), After logging out of OutSystems, redirect the user to Azure AD’s logout endpoint:

https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/logout ?post_logout_redirect_uri={ENCODED_RETURN_URL} &prompt=login

Hope this helps,

Cheers,

Saugat

UserImage.jpg
João Espinheira

it does. the problem stands with the webview cookies. I dont know how to clear them. Everything i try seems to not work

2026-03-20 01-28-51
Saugat Biswas

Ensure you are redirecting to logout url wih prompt=login.

https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/logout ?post_logout_redirect_uri={ENCODED_RETURN_URL} &prompt=login

If the issue still persists, have a separate screen for Logout with single link in the middle of the screen to "Go back to login" and provide the new logout screen name in the ENCODED_RETURN_URL.

?post_logout_redirect_uri={ENCODED_RETURN_URL} 

UserImage.jpg
João Espinheira

i do that, but since my login is from authauth, when it gets there, the cached values from login still persist

2018-12-10 12-16-21
Goncalo Duarte Almeida

Hello @João Espinheira 


You’re probably logging out only from the OutSystems session, not from the Azure session that lives in the webview.

In mobile, that means when you hit the login page again, Azure still has a valid session and performs SSO automatically, so it looks like logout didn’t work.

Check this points: 

1. Call the IdP logout endpoint as part of logout, not only the OutSystems logout. In OutSystems, external-IdP logout should redirect the user to the provider logout flow as well.

2. Clear the webview/browser session if you are using an embedded webview, because the cookie jar may still be there after app logout. 

3.C heck persistent login settings in OutSystems mobile auth. In OutSystems persistent login is enabled by default for mobile apps and its duration is configurable, so even after logout cycles this can affect what you see.

So to fix this you need to OutSystems logout + Azure logout + clear webview cookies. Just redirecting back to the login screen is normally not enough.

UserImage.jpg
João Espinheira

how can i clear webview cookies? 

2018-12-10 12-16-21
Goncalo Duarte Almeida

Hello @João Espinheira 

You can try using this Forge component: https://www.outsystems.com/forge/component-overview/1558/inappbrowser-plugin-o11

2024-10-05 13-30-20
Huy Hoang The

Hi @João Espinheira ,

Because you are using SSO, you just logout OS, when you log in again, it's redirect to SSO and passed a SSO log in . So you must log out of SSO before you log out of OS.

For Logout SSO, i remember we have a URL from the provider as Saugat mentioned.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.