From 565387464c60d7128bcc25fba71f98210eac0885 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Fri, 4 Apr 2025 10:33:06 +0530 Subject: [PATCH] fix: on adding redirectUrl to the logout function, the url was not encoded (#40071) --- .../ActionSelector_JsToNonJSMode_4_spec.ts | 25 +++++++++++++++++++ app/client/src/ce/sagas/userSagas.tsx | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_4_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_4_spec.ts index 32aff93703..dc4ced9e32 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_4_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_4_spec.ts @@ -78,5 +78,30 @@ describe( ); }); }); + + it("3. should logout user successfully using global logoutUser function and should redirect to the url provided with multiple query params", () => { + let applicationUrl = ""; + EditorNavigation.SelectEntityByName("Page1", EntityType.Page); + EditorNavigation.SelectEntityByName("Button1", EntityType.Widget); + propPane.EnterJSContext( + "onClick", + "{{logoutUser('/abc/def?test1=123&test2=456')}}", + true, + false, + ); + cy.location().then((loc) => { + propPane.ToggleJSMode("onClick", false); + propPane.UpdatePropertyFieldValue("Label", ""); + propPane.TypeTextIntoField("Label", "LOGOUT GLOBAL"); + agHelper.ClickButton("LOGOUT GLOBAL"); + cy.location().should((loc) => { + expect(loc.pathname).to.eq("/user/login"); + expect(loc.search).to.eq( + "?redirectUrl=" + + encodeURIComponent("/abc/def?test1=123&test2=456"), + ); + }); + }); + }); }, ); diff --git a/app/client/src/ce/sagas/userSagas.tsx b/app/client/src/ce/sagas/userSagas.tsx index acbabc0185..874d041f04 100644 --- a/app/client/src/ce/sagas/userSagas.tsx +++ b/app/client/src/ce/sagas/userSagas.tsx @@ -728,7 +728,7 @@ export const setMessageConfig = (id: string, config: ProductAlertConfig) => { export function* globalFunctionLogoutUser( action: ReduxAction<{ redirectURL: string }>, ) { - const redirectURL = `${AUTH_LOGIN_URL}?redirectUrl=${action.payload?.redirectURL ? action.payload?.redirectURL : history.location.pathname}`; + const redirectURL = `${AUTH_LOGIN_URL}?redirectUrl=${encodeURIComponent(action.payload?.redirectURL ? action.payload?.redirectURL : history.location.pathname)}`; yield call(logoutSaga, { type: ReduxActionTypes.LOGOUT_USER_INIT,