File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -279,10 +279,18 @@ export const createUserManager = async (options: CreateUserManagerOptions) => {
279
279
* Logs out the user from the auth server and calls the callback function when the logout is complete.
280
280
* @param WSLogoutAndRedirect - The callback function to call after the logout is complete
281
281
*/
282
- export const OAuth2Logout = ( options : OAuth2LogoutOptions ) => {
282
+ export const OAuth2Logout = async ( options : OAuth2LogoutOptions ) => {
283
283
const oidcEndpoints = localStorage . getItem ( 'config.oidc_endpoints' ) || '{}' ;
284
284
285
- const logoutUrl = getOAuthLogoutUrl ( ) || JSON . parse ( oidcEndpoints ) . end_session_endpoint ;
285
+ let logoutUrl = getOAuthLogoutUrl ( ) || JSON . parse ( oidcEndpoints ) . end_session_endpoint ;
286
+ const userManager = await createUserManager ( {
287
+ redirectCallbackUri : options . redirectCallbackUri ,
288
+ postLogoutRedirectUri : options . postLogoutRedirectUri ,
289
+ } ) ;
290
+ const userState = await userManager . getUser ( ) ;
291
+ if ( userState ?. id_token ) {
292
+ logoutUrl += `?id_token_hint=${ userState . id_token } &post_logout_redirect_uri${ options . postLogoutRedirectUri } ` ;
293
+ }
286
294
287
295
const cleanup = ( ) => {
288
296
const iframe = document . getElementById ( 'logout-iframe' ) as HTMLIFrameElement ;
You can’t perform that action at this time.
0 commit comments