From 2fdc2d84ff1aa8348396fed389ec463ce753919f Mon Sep 17 00:00:00 2001 From: Timofey Boyko Date: Wed, 29 Nov 2023 16:10:40 +0300 Subject: [PATCH] OAuth2: remove useless cookie --- packages/common/api/oauth/index.ts | 10 ++++++++++ packages/common/utils/axiosClient.js | 1 - .../src/client/components/sub-components/Consent.tsx | 3 --- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/common/api/oauth/index.ts b/packages/common/api/oauth/index.ts index 78bfe2b56c..3c36500064 100644 --- a/packages/common/api/oauth/index.ts +++ b/packages/common/api/oauth/index.ts @@ -139,6 +139,10 @@ export const onOAuthLogin = () => { method: "post", url: `/oauth2/login`, data: formData, + withRedirect: true, + headers: { + "X-Disable-Redirect": true, + }, }); }; @@ -161,6 +165,9 @@ export const onOAuthSubmit = ( url: `/oauth2/authorize`, data: formData, withRedirect: true, + headers: { + "X-Disable-Redirect": true, + }, }); }; @@ -175,6 +182,9 @@ export const onOAuthCancel = (clientId: string, clientState: string) => { url: `/oauth2/authorize`, data: formData, withRedirect: true, + headers: { + "X-Disable-Redirect": true, + }, }); }; diff --git a/packages/common/utils/axiosClient.js b/packages/common/utils/axiosClient.js index 1dcdd55a04..9dec7e43c3 100644 --- a/packages/common/utils/axiosClient.js +++ b/packages/common/utils/axiosClient.js @@ -130,7 +130,6 @@ class AxiosClient { if (error) throw new Error(error); if (response.headers["x-redirect-uri"] && options.withRedirect) { - deleteCookie("disable_redirect"); return window.location.replace(response.headers["x-redirect-uri"]); } diff --git a/packages/login/src/client/components/sub-components/Consent.tsx b/packages/login/src/client/components/sub-components/Consent.tsx index 54604d5088..3a9ce97cef 100644 --- a/packages/login/src/client/components/sub-components/Consent.tsx +++ b/packages/login/src/client/components/sub-components/Consent.tsx @@ -92,7 +92,6 @@ const Consent = ({ let clientState = ""; const scope = oauth.client.scopes; - setCookie("disable_redirect", true); setCookie("client_id", clientId); await api.oauth.onOAuthLogin(); @@ -117,8 +116,6 @@ const Consent = ({ setCookie("client_id", clientId); - setCookie("disable_redirect", true); - await api.oauth.onOAuthLogin(); const cookie = document.cookie.split(";");