redirect to challenges page after logout
This commit is contained in:
parent
3ff0c6ea87
commit
d88bb1d0ea
@ -9,6 +9,8 @@ import {
|
|||||||
CHALLENGES_PAGE,
|
CHALLENGES_PAGE,
|
||||||
IS_MOBILE,
|
IS_MOBILE,
|
||||||
POLICY_PRIVACY_PAGE,
|
POLICY_PRIVACY_PAGE,
|
||||||
|
LOGIN_REQUIRED_PAGES,
|
||||||
|
ROOT_URL,
|
||||||
} from './utils/globals';
|
} from './utils/globals';
|
||||||
import KeyCloakService from './services/KeyCloakService';
|
import KeyCloakService from './services/KeyCloakService';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@ -28,6 +30,13 @@ const App = () => {
|
|||||||
const [confirmPopUpHandler, setConfirmPopUpHandler] = React.useState(null);
|
const [confirmPopUpHandler, setConfirmPopUpHandler] = React.useState(null);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
if (sessionStorage.getItem('logout') === 'yes') {
|
||||||
|
const pageName = window.location.pathname.split('/').at(-1);
|
||||||
|
if (LOGIN_REQUIRED_PAGES.includes(pageName)) {
|
||||||
|
window.location.replace(`${ROOT_URL}/challenges`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sessionStorage.getItem('logged') !== 'yes') {
|
if (sessionStorage.getItem('logged') !== 'yes') {
|
||||||
if (KeyCloakService.isLoggedIn()) {
|
if (KeyCloakService.isLoggedIn()) {
|
||||||
sessionStorage.setItem('logged', 'yes');
|
sessionStorage.setItem('logged', 'yes');
|
||||||
|
@ -30,12 +30,14 @@ const doLogin = () => {
|
|||||||
if (privacyPolicyAccept !== 'accept') {
|
if (privacyPolicyAccept !== 'accept') {
|
||||||
window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}/login`;
|
window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}/login`;
|
||||||
} else {
|
} else {
|
||||||
|
sessionStorage.setItem('logout', '');
|
||||||
_kc.login();
|
_kc.login();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const doLogout = () => {
|
const doLogout = () => {
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
|
sessionStorage.setItem('logout', 'yes');
|
||||||
_kc.logout();
|
_kc.logout();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ const POLICY_PRIVACY_PAGE = '/policy-privacy';
|
|||||||
const CSI_LINK = 'https://csi.amu.edu.pl/';
|
const CSI_LINK = 'https://csi.amu.edu.pl/';
|
||||||
const ROOT_URL = window.location.origin;
|
const ROOT_URL = window.location.origin;
|
||||||
|
|
||||||
|
const LOGIN_REQUIRED_PAGES = ['myentries', 'submit', 'howto'];
|
||||||
|
|
||||||
const MINI_DESCRIPTION_RENDER = (description) => {
|
const MINI_DESCRIPTION_RENDER = (description) => {
|
||||||
if (description) {
|
if (description) {
|
||||||
if (description.length <= MINI_DESCRIPTION_LENGTH) return description;
|
if (description.length <= MINI_DESCRIPTION_LENGTH) return description;
|
||||||
@ -83,6 +85,7 @@ export {
|
|||||||
CSI_LINK,
|
CSI_LINK,
|
||||||
POLICY_PRIVACY_PAGE,
|
POLICY_PRIVACY_PAGE,
|
||||||
ROOT_URL,
|
ROOT_URL,
|
||||||
|
LOGIN_REQUIRED_PAGES,
|
||||||
MINI_DESCRIPTION_RENDER,
|
MINI_DESCRIPTION_RENDER,
|
||||||
RENDER_ICO,
|
RENDER_ICO,
|
||||||
CALC_PAGES,
|
CALC_PAGES,
|
||||||
|
Loading…
Reference in New Issue
Block a user