From 7b4d36df47c4643045bccf146cf9f4d6a8210586 Mon Sep 17 00:00:00 2001 From: Daniel Rivers Date: Fri, 19 Jul 2024 17:51:01 +0100 Subject: [PATCH] fix: Post logout redirect URL --- src/handlers/logout.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/handlers/logout.js b/src/handlers/logout.js index ef79515..8728e6f 100644 --- a/src/handlers/logout.js +++ b/src/handlers/logout.js @@ -1,3 +1,4 @@ +import { config } from '../config/index'; import RouterClient from '../routerClients/RouterClient'; /** @@ -6,21 +7,15 @@ import RouterClient from '../routerClients/RouterClient'; */ export const logout = async (routerClient) => { const authUrl = await routerClient.kindeClient.logout( - routerClient.sessionManager, - { - authUrlParams: Object.fromEntries(routerClient.searchParams) - } - ); - - const postLogoutRedirectURL = routerClient.getSearchParam( - 'post_logout_redirect_url' + routerClient.sessionManager ); + let postLogoutRedirectURL = routerClient.getSearchParam('post_logout_redirect_url') || config.postLogoutRedirectURL; + if (postLogoutRedirectURL?.startsWith('/')) { + postLogoutRedirectURL = config.redirectURL + postLogoutRedirectURL; + } if (postLogoutRedirectURL) { - await routerClient.sessionManager.setSessionItem( - 'post_logout_redirect_url', - postLogoutRedirectURL - ); + authUrl.searchParams.set('redirect', postLogoutRedirectURL); } return routerClient.redirect(authUrl.toString());