From 4ca49ed173c5085572fb0aa0458fe32f0d8d749c Mon Sep 17 00:00:00 2001 From: Timofey Boyko Date: Tue, 28 Nov 2023 18:51:02 +0300 Subject: [PATCH] OAuth2: add disable redirect cookie --- packages/common/utils/axiosClient.js | 3 ++- .../src/client/components/sub-components/Consent.tsx | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/common/utils/axiosClient.js b/packages/common/utils/axiosClient.js index d1766460d2..1dcdd55a04 100644 --- a/packages/common/utils/axiosClient.js +++ b/packages/common/utils/axiosClient.js @@ -1,6 +1,6 @@ import axios from "axios"; -import { setCookie } from "./"; +import { setCookie, deleteCookie } from "./"; import combineUrl from "./combineUrl"; import defaultConfig from "PUBLIC_DIR/scripts/config.json"; @@ -130,6 +130,7 @@ 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 3f8ea26b29..39c0d708aa 100644 --- a/packages/login/src/client/components/sub-components/Consent.tsx +++ b/packages/login/src/client/components/sub-components/Consent.tsx @@ -103,10 +103,10 @@ const Consent = ({ clientState = c.replace("client_state=", "").trim(); }); - console.log(clientState); + deleteCookie("client_id"); + deleteCookie("client_state"); - // deleteCookie("client_id"); - // deleteCookie("client_state"); + setCookie("disable_redirect", true); await api.oauth.onOAuthSubmit(clientId, clientState, scope); }; @@ -130,6 +130,8 @@ const Consent = ({ deleteCookie("client_id"); deleteCookie("client_state"); + setCookie("disable_redirect", true); + await api.oauth.onOAuthCancel(clientId, clientState); };