redirect to challenges page when logged after accepting policy privacy

This commit is contained in:
Mateusz Tylka 2023-03-31 09:06:26 +02:00
parent d88bb1d0ea
commit 45601ce05c
2 changed files with 10 additions and 2 deletions

View File

@ -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(() => { setTimeout(() => {
if (sessionStorage.getItem('logged') === 'yes') { if (sessionStorage.getItem('logged') === 'yes') {
if (!KeyCloakService.isLoggedIn()) { if (!KeyCloakService.isLoggedIn()) {

View File

@ -28,7 +28,7 @@ const initKeycloak = (onAuthenticatedCallback) => {
const doLogin = () => { const doLogin = () => {
const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); const privacyPolicyAccept = localStorage.getItem('privacyPolicy');
if (privacyPolicyAccept !== 'accept') { if (privacyPolicyAccept !== 'accept') {
window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}/login`; window.location.replace(`${ROOT_URL}${POLICY_PRIVACY_PAGE}/login`);
} else { } else {
sessionStorage.setItem('logout', ''); sessionStorage.setItem('logout', '');
_kc.login(); _kc.login();
@ -46,7 +46,7 @@ const getToken = () => _kc.token;
const doRegister = () => { const doRegister = () => {
const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); const privacyPolicyAccept = localStorage.getItem('privacyPolicy');
if (privacyPolicyAccept !== 'accept') { if (privacyPolicyAccept !== 'accept') {
window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}/register`; window.location.replace(`${ROOT_URL}${POLICY_PRIVACY_PAGE}/register`);
} else { } else {
_kc.register(); _kc.register();
} }