Files
planka_custom/client/src/sagas/core/index.js
T
2023-10-19 16:05:34 +02:00

27 lines
803 B
JavaScript
Executable File

import { all, apply, fork, select, take } from 'redux-saga/effects';
import watchers from './watchers';
import services from './services';
import selectors from '../../selectors';
import { socket } from '../../api';
import ActionTypes from '../../constants/ActionTypes';
import Paths from '../../constants/Paths';
export default function* coreSaga() {
yield all(watchers.map((watcher) => fork(watcher)));
yield apply(socket, socket.connect);
yield fork(services.initializeCore);
yield take(ActionTypes.LOGOUT);
const oidcConfig = yield select(selectors.selectOidcConfig);
if (oidcConfig && oidcConfig.endSessionUrl !== null) {
// Redirect the user to the IDP to log out.
window.location.href = oidcConfig.endSessionUrl;
} else {
window.location.href = Paths.LOGIN;
}
}