From 45601ce05cd52d84defc744a8835d48a4e1fc39a Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Fri, 31 Mar 2023 09:06:26 +0200 Subject: [PATCH] redirect to challenges page when logged after accepting policy privacy --- src/App.js | 8 ++++++++ src/services/KeyCloakService.js | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index ea79637..6a600d2 100644 --- a/src/App.js +++ b/src/App.js @@ -44,6 +44,14 @@ const App = () => { } } + if ( + sessionStorage.getItem('logged') === 'yes' && + (window.location.pathname === `${POLICY_PRIVACY_PAGE}/login` || + window.location.pathname === `${POLICY_PRIVACY_PAGE}/register`) + ) { + window.location.replace(`${ROOT_URL}/challenges`); + } + setTimeout(() => { if (sessionStorage.getItem('logged') === 'yes') { if (!KeyCloakService.isLoggedIn()) { diff --git a/src/services/KeyCloakService.js b/src/services/KeyCloakService.js index 66d6619..47e15b9 100644 --- a/src/services/KeyCloakService.js +++ b/src/services/KeyCloakService.js @@ -28,7 +28,7 @@ const initKeycloak = (onAuthenticatedCallback) => { const doLogin = () => { const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); if (privacyPolicyAccept !== 'accept') { - window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}/login`; + window.location.replace(`${ROOT_URL}${POLICY_PRIVACY_PAGE}/login`); } else { sessionStorage.setItem('logout', ''); _kc.login(); @@ -46,7 +46,7 @@ const getToken = () => _kc.token; const doRegister = () => { const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); if (privacyPolicyAccept !== 'accept') { - window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}/register`; + window.location.replace(`${ROOT_URL}${POLICY_PRIVACY_PAGE}/register`); } else { _kc.register(); }