This commit is contained in:
Mateusz Tylka 2023-02-01 14:26:33 +01:00
commit 1c6655f62b
3 changed files with 11 additions and 4 deletions

2
.env
View File

@ -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

View File

@ -12,4 +12,4 @@ App will work on port 3000.
## Keycloak
Set variables in *.env* to choose keycloak connect.
Set variables in *.env* to choose keycloak connect and API url.

View File

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