Enhancement Request: Allow `logout` to be passed arguments for `state`
See original GitHub issueEnhancement Request: Allow logout
to be passed arguments for state
As near as I can tell, under the hood, react-oidc
is calling into oidc-client-js
’s UserManager
’s signoutRedirect
instance method in order to prompt a logout. signoutRedirect
accepts an args
object, which can include a state
property, which would be forwarded to any URL passed for end_session_endpoint
as a query param.
It would be nice if the logout
method made available via the various packages could be made to accept args
(or possibly just state
) so that it could be passed through to react-oidc
’s signoutRedirect
. For instance, in the context variant, changing logoutCallback
to something like this:
const logoutCallback = useCallback(async (args = {}) => {
try {
onLogout();
await logoutUserInt(userManager, args);
oidcLogInt.info('Logout successfull');
} catch (error) {
onError(error.message);
}
}, [logoutUserInt, oidcLogInt, onError, onLogout, userManager]);
and logoutUser
in oidcServices.ts
to something like this:
export const logoutUser = async (userManager: UserManager, args) => {
if (!userManager || !userManager.getUser) {
return;
}
const oidcUser = await userManager.getUser();
if (oidcUser) {
oidcLog.info('Logout user...');
await userManager.signoutRedirect(args);
}
};
would enable leveraging of state. That’s obviously a rough, not very Typescripty example, but it is the sort of thing I am envisioning.
Being able to pass state through would allow us to take different actions on the way back into the application based on how the user was logged out. For example, we could opt to show a warning on the screen if they were logged out programmatically rather than by user action.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top GitHub Comments
Hello. You just have to make a PR from a fork. We can’t add you in the contributors because of internal Axa Policies.
But don’t worry it’s very simple to contribute from a fork.
@guillaume-chervet @youf-olivier do you mind if I open a PR for this?