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:
parent
36947e2f47
commit
b7780f86a5
2 changed files with 28 additions and 15 deletions
|
@ -124,6 +124,7 @@ const Login = React.memo(
|
||||||
case 'Invalid credentials':
|
case 'Invalid credentials':
|
||||||
case 'Invalid email or username':
|
case 'Invalid email or username':
|
||||||
emailOrUsernameField.current.select();
|
emailOrUsernameField.current.select();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Invalid password':
|
case 'Invalid password':
|
||||||
setData((prevData) => ({
|
setData((prevData) => ({
|
||||||
|
@ -131,6 +132,7 @@ const Login = React.memo(
|
||||||
password: '',
|
password: '',
|
||||||
}));
|
}));
|
||||||
focusPasswordField();
|
focusPasswordField();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
@ -141,13 +143,6 @@ const Login = React.memo(
|
||||||
passwordField.current.focus();
|
passwordField.current.focus();
|
||||||
}, [focusPasswordFieldState]);
|
}, [focusPasswordFieldState]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const params = new URLSearchParams(window.location.search);
|
|
||||||
if (params.has('enforce_oidc_login')) {
|
|
||||||
onAuthenticateUsingOidc();
|
|
||||||
}
|
|
||||||
}, [onAuthenticateUsingOidc]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.wrapper, styles.fullHeight)}>
|
<div className={classNames(styles.wrapper, styles.fullHeight)}>
|
||||||
<Grid verticalAlign="middle" className={styles.fullHeightPaddingFix}>
|
<Grid verticalAlign="middle" className={styles.fullHeightPaddingFix}>
|
||||||
|
@ -254,10 +249,12 @@ const Login = React.memo(
|
||||||
);
|
);
|
||||||
|
|
||||||
Login.propTypes = {
|
Login.propTypes = {
|
||||||
|
/* eslint-disable react/forbid-prop-types */
|
||||||
defaultData: PropTypes.object.isRequired,
|
defaultData: PropTypes.object.isRequired,
|
||||||
|
/* eslint-enable react/forbid-prop-types */
|
||||||
isSubmitting: PropTypes.bool.isRequired,
|
isSubmitting: PropTypes.bool.isRequired,
|
||||||
isSubmittingUsingOidc: PropTypes.bool.isRequired,
|
isSubmittingUsingOidc: PropTypes.bool.isRequired,
|
||||||
error: PropTypes.object,
|
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||||
withOidc: PropTypes.bool.isRequired,
|
withOidc: PropTypes.bool.isRequired,
|
||||||
isOidcEnforced: PropTypes.bool.isRequired,
|
isOidcEnforced: PropTypes.bool.isRequired,
|
||||||
onAuthenticate: PropTypes.func.isRequired,
|
onAuthenticate: PropTypes.func.isRequired,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { call, put, select, take } from 'redux-saga/effects';
|
import { call, put, select, take } from 'redux-saga/effects';
|
||||||
import { push } from '../../../lib/redux-router';
|
import { push } from '../../../lib/redux-router';
|
||||||
|
|
||||||
import { authenticateUsingOidcCallback } from './login';
|
import { authenticateUsingOidc, authenticateUsingOidcCallback } from './login';
|
||||||
import selectors from '../../../selectors';
|
import selectors from '../../../selectors';
|
||||||
import ActionTypes from '../../../constants/ActionTypes';
|
import ActionTypes from '../../../constants/ActionTypes';
|
||||||
import Paths from '../../../constants/Paths';
|
import Paths from '../../../constants/Paths';
|
||||||
|
@ -29,17 +29,33 @@ export function* handleLocationChange() {
|
||||||
yield call(goToLogin);
|
yield call(goToLogin);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Paths.OIDC_CALLBACK: {
|
default:
|
||||||
const isInitializing = yield select(selectors.selectIsInitializing);
|
}
|
||||||
|
|
||||||
if (isInitializing) {
|
const isInitializing = yield select(selectors.selectIsInitializing);
|
||||||
yield take(ActionTypes.LOGIN_INITIALIZE);
|
|
||||||
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
case Paths.OIDC_CALLBACK:
|
||||||
|
yield call(authenticateUsingOidcCallback);
|
||||||
|
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue