From 87e9c7dd5159c1d08368bfafa30fed9ae811933c Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 3 Apr 2023 13:11:18 +0100 Subject: First pass --- modern/src/login/LoginPage.js | 155 +++++++++++++++++++------------------- modern/src/resources/l10n/en.json | 3 +- 2 files changed, 79 insertions(+), 79 deletions(-) (limited to 'modern/src') diff --git a/modern/src/login/LoginPage.js b/modern/src/login/LoginPage.js index 4f10ce46..b572b4ea 100644 --- a/modern/src/login/LoginPage.js +++ b/modern/src/login/LoginPage.js @@ -54,14 +54,16 @@ const LoginPage = () => { const [failed, setFailed] = useState(false); + const [loading, setLoading] = useState(false); + const [email, setEmail] = usePersistedState('loginEmail', ''); const [password, setPassword] = useState(''); const registrationEnabled = useSelector((state) => state.session.server.registration); const languageEnabled = useSelector((state) => !state.session.server.attributes['ui.disableLoginLanguage']); const emailEnabled = useSelector((state) => state.session.server.emailEnabled); - const oidcEnabled = useSelector((state) => state.session.server.oidcEnabled); - const oidcForced = useSelector((state) => state.session.server.oidcEnabled && state.session.server.oidcForce); + const openIdEnabled = useSelector((state) => state.session.server.openIdEnabled); + const openIdForced = useSelector((state) => state.session.server.openIdEnabled && state.session.server.openIdForce); const [announcementShown, setAnnouncementShown] = useState(false); const announcement = useSelector((state) => state.session.server.announcement); @@ -123,6 +125,11 @@ const LoginPage = () => { } }; + const handleOpenIdLogin = () => { + setLoading(true); + document.location = '/api/session/openid/auth'; + } + useEffect(() => nativePostMessage('authentication'), []); useEffect(() => { @@ -132,10 +139,10 @@ const LoginPage = () => { }, []); useEffect(() => { - if (oidcForced) { - document.location = '/api/session/openid/auth'; + if (openIdForced) { + handleOpenIdLogin(); } - }, [oidcForced]); + }, [openIdForced]); return ( @@ -148,85 +155,79 @@ const LoginPage = () => { )} - {oidcForced ? ( -
- {t('loginOIDCRedirect')} -
- ) : ( -
- {useMediaQuery(theme.breakpoints.down('lg')) && } - setEmail(e.target.value)} - onKeyUp={handleSpecialKey} - helperText={failed && 'Invalid username or password'} - /> - setPassword(e.target.value)} - onKeyUp={handleSpecialKey} - /> +
+ {useMediaQuery(theme.breakpoints.down('lg')) && } + setEmail(e.target.value)} + onKeyUp={handleSpecialKey} + helperText={failed && 'Invalid username or password'} + /> + setPassword(e.target.value)} + onKeyUp={handleSpecialKey} + /> + + {openIdEnabled && ( - {oidcEnabled && ( - - )} -
- - {languageEnabled && ( - - {t('loginLanguage')} - - - )} -
- {emailEnabled && ( - navigate('/reset-password')} - className={classes.resetPassword} - underline="none" - variant="caption" - > - {t('loginReset')} - + )} +
+ + {languageEnabled && ( + + {t('loginLanguage')} + + )}
- )} + {emailEnabled && ( + navigate('/reset-password')} + className={classes.resetPassword} + underline="none" + variant="caption" + > + {t('loginReset')} + + )} +