1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

ref: Move logic from component to saga

This commit is contained in:
Maksim Eltyshev 2025-04-21 00:52:49 +02:00
parent 36947e2f47
commit b7780f86a5
2 changed files with 28 additions and 15 deletions

View file

@ -124,6 +124,7 @@ const Login = React.memo(
case 'Invalid credentials':
case 'Invalid email or username':
emailOrUsernameField.current.select();
break;
case 'Invalid password':
setData((prevData) => ({
@ -131,6 +132,7 @@ const Login = React.memo(
password: '',
}));
focusPasswordField();
break;
default:
}
@ -141,13 +143,6 @@ const Login = React.memo(
passwordField.current.focus();
}, [focusPasswordFieldState]);
useEffect(() => {
const params = new URLSearchParams(window.location.search);
if (params.has('enforce_oidc_login')) {
onAuthenticateUsingOidc();
}
}, [onAuthenticateUsingOidc]);
return (
<div className={classNames(styles.wrapper, styles.fullHeight)}>
<Grid verticalAlign="middle" className={styles.fullHeightPaddingFix}>
@ -254,10 +249,12 @@ const Login = React.memo(
);
Login.propTypes = {
/* eslint-disable react/forbid-prop-types */
defaultData: PropTypes.object.isRequired,
/* eslint-enable react/forbid-prop-types */
isSubmitting: PropTypes.bool.isRequired,
isSubmittingUsingOidc: PropTypes.bool.isRequired,
error: PropTypes.object,
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
withOidc: PropTypes.bool.isRequired,
isOidcEnforced: PropTypes.bool.isRequired,
onAuthenticate: PropTypes.func.isRequired,

View file

@ -1,7 +1,7 @@
import { call, put, select, take } from 'redux-saga/effects';
import { push } from '../../../lib/redux-router';
import { authenticateUsingOidcCallback } from './login';
import { authenticateUsingOidc, authenticateUsingOidcCallback } from './login';
import selectors from '../../../selectors';
import ActionTypes from '../../../constants/ActionTypes';
import Paths from '../../../constants/Paths';
@ -29,17 +29,33 @@ export function* handleLocationChange() {
yield call(goToLogin);
break;
case Paths.OIDC_CALLBACK: {
const isInitializing = yield select(selectors.selectIsInitializing);
default:
}
if (isInitializing) {
yield take(ActionTypes.LOGIN_INITIALIZE);
const isInitializing = yield select(selectors.selectIsInitializing);
if (isInitializing) {
yield take(ActionTypes.LOGIN_INITIALIZE);
}
switch (pathsMatch.pattern.path) {
case Paths.LOGIN: {
const oidcConfig = yield select(selectors.selectOidcConfig);
if (oidcConfig) {
const params = new URLSearchParams(window.location.search);
if (params.has('authenticateWithOidc')) {
yield call(authenticateUsingOidc);
}
}
yield call(authenticateUsingOidcCallback);
break;
}
case Paths.OIDC_CALLBACK:
yield call(authenticateUsingOidcCallback);
break;
default:
}
}