fix: on adding redirectUrl to the logout function, the url was not encoded (#40071)

This commit is contained in:
Aman Agarwal 2025-04-04 10:33:06 +05:30 committed by GitHub
parent 3f8ce79e4b
commit 565387464c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -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"),
);
});
});
});
}, },
); );

View File

@ -728,7 +728,7 @@ export const setMessageConfig = (id: string, config: ProductAlertConfig) => {
export function* globalFunctionLogoutUser( export function* globalFunctionLogoutUser(
action: ReduxAction<{ redirectURL: string }>, 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, { yield call(logoutSaga, {
type: ReduxActionTypes.LOGOUT_USER_INIT, type: ReduxActionTypes.LOGOUT_USER_INIT,