Log a user out of your app
Clear the tokens and account data of your app on logout, and optionally send the user through the RemiliaNET end-session flow.
Clear local state before any request to the provider, so the user is logged out of your app even when the provider cannot be reached. Logout does not revoke tokens. For the difference, see Logout and revocation.
Prerequisites
- A
clearAppTokens()function that clears the access, refresh, and ID tokens of your app. The refresh task uses the same function. - For RemiliaNET logout, a return URL that matches a registered redirect URI exactly.
Steps
-
Invalidate the pending login, refresh, and profile requests of your app.
-
Keep the ID token in a variable for the logout hint.
-
Call
clearAppTokens(). -
Clear the account data, the account display, and the pending operations.
-
If you also log the user out of RemiliaNET, redirect to
end_session_endpoint:const idTokenHint = storedIdToken; clearAppTokens(); const params = new URLSearchParams({ client_id: "YOUR_CLIENT_ID", post_logout_redirect_uri: "https://yourapp.example/", id_token_hint: idTokenHint, }); window.location.assign( "https://www.remilia.net/oidc/realms/remilia/protocol/openid-connect/logout" + `?${params}`, );
Result
The user is logged out of your app. Late results of earlier requests cannot restore tokens or overwrite a later login. If a provider request fails, the user stays logged out of your app.
The end-session flow requests logout from RemiliaNET. A redirect that starts does not prove that logout completed. The local sessions of other apps stay separate. The end-session parameters describe each value of step 5.
