From 0cd425ea2344d1999bb6b53422c9adb44d54e9a0 Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Mon, 16 Jan 2023 11:38:32 +0100 Subject: [PATCH 1/2] README update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77ec01b..121cb62 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,4 @@ App will work on port 3000. ## Keycloak -Set variables in *.env* to choose keycloak connect. \ No newline at end of file +Set variables in *.env* to choose keycloak connect and API url. \ No newline at end of file From 2bb962b00210bc23d4898acbc2c44bf3c1244aa7 Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Wed, 18 Jan 2023 16:03:32 +0100 Subject: [PATCH 2/2] redirect to privacy policy correction --- .env | 2 +- src/services/KeyCloakService.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.env b/.env index c6a5580..0c0a154 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ REACT_APP_KC_URL=https://auth-dev.csi.wmi.amu.edu.pl/ REACT_APP_KC_REALM=gonito-dev -REACT_APP_KC_CLIENT_ID=gonito-dev-heroku +REACT_APP_KC_CLIENT_ID=gonito-dev-localhost REACT_APP_API=https://gonito.net/api diff --git a/src/services/KeyCloakService.js b/src/services/KeyCloakService.js index 9eb32f8..a9c9ecc 100644 --- a/src/services/KeyCloakService.js +++ b/src/services/KeyCloakService.js @@ -25,7 +25,14 @@ const initKeycloak = (onAuthenticatedCallback) => { .catch(console.error); }; -const doLogin = _kc.login; +const doLogin = () => { + const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); + if (privacyPolicyAccept !== 'accept') { + window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}`; + } else { + _kc.login(); + } +}; const doLogout = () => { sessionStorage.clear(); @@ -37,7 +44,7 @@ const getToken = () => _kc.token; const doRegister = () => { const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); if (privacyPolicyAccept !== 'accept') { - window.location.replace(`${ROOT_URL}${POLICY_PRIVACY_PAGE}`); + window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}`; } else { _kc.register(); }