From b569083db60c86fad7c7f4d0087fc1e76e2f57c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Mon, 5 Aug 2024 02:29:42 +0200 Subject: [PATCH] feat: add login grid --- assets/pages/LoginPage.tsx | 108 +++++++++++++++++------------- src/Security/JWTAuthenticator.php | 2 +- translations/translations.pot | 18 ++--- 3 files changed, 70 insertions(+), 58 deletions(-) diff --git a/assets/pages/LoginPage.tsx b/assets/pages/LoginPage.tsx index e42ab79..dde4018 100644 --- a/assets/pages/LoginPage.tsx +++ b/assets/pages/LoginPage.tsx @@ -1,13 +1,19 @@ import React, {createContext, useContext, useEffect, useState} from "react"; -import {Alert, Button, Card, Flex, Form, Input} from "antd"; +import {Alert, Button, Card, Form, Input} from "antd"; import {getConfiguration, getUser, InstanceConfig, login} from "../utils/api"; import {useNavigate} from "react-router-dom"; import {t} from 'ttag' +import TextPage from "./TextPage"; type FieldType = { username: string; password: string; -}; +} + +const gridStyle: React.CSSProperties = { + width: '50%', + textAlign: 'center', +} export const AuthenticatedContext = createContext(null) @@ -24,7 +30,11 @@ export default function LoginPage() { navigate('/home') }).catch((e) => { setIsAuthenticated(false) - setError(e.response.data.message) + if (e.response.data.message !== undefined) { + setError(e.response.data.message) + } else { + setError(e.response.data['hydra:description']) + } }) } @@ -36,53 +46,55 @@ export default function LoginPage() { getConfiguration().then(setConfiguration) }, []) - return - {error && - } -
- + + {error && + } + - - + + + - - label={t`Password`} - name="password" - rules={[{required: true, message: t`Required`}]} - > - - + + label={t`Password`} + name="password" + rules={[{required: true, message: t`Required`}]} + > + + - - - - {configuration?.ssoLogin && - - } - + + + + {configuration?.ssoLogin && + + } + + + + +
-
} \ No newline at end of file diff --git a/src/Security/JWTAuthenticator.php b/src/Security/JWTAuthenticator.php index f19e2c0..7fd00ca 100644 --- a/src/Security/JWTAuthenticator.php +++ b/src/Security/JWTAuthenticator.php @@ -33,7 +33,7 @@ readonly class JWTAuthenticator implements AuthenticationSuccessHandlerInterface public function handleAuthenticationSuccess(UserInterface $user, $jwt = null): Response { if (($user instanceof User) && !$user->isVerified()) { - throw new AccessDeniedHttpException('This user has not yet validated their email address.'); + throw new AccessDeniedHttpException('You have not yet validated your email address.'); } if (null === $jwt) { diff --git a/translations/translations.pot b/translations/translations.pot index 4528fb4..b5e77dc 100644 --- a/translations/translations.pot +++ b/translations/translations.pot @@ -57,8 +57,8 @@ msgstr "" #: assets/components/tracking/ConnectorForm.tsx:110 #: assets/components/tracking/ConnectorForm.tsx:119 #: assets/components/tracking/WatchlistForm.tsx:103 -#: assets/pages/LoginPage.tsx:62 -#: assets/pages/LoginPage.tsx:70 +#: assets/pages/LoginPage.tsx:71 +#: assets/pages/LoginPage.tsx:79 msgid "Required" msgstr "" @@ -326,7 +326,7 @@ msgid "Log out" msgstr "" #: assets/components/Sider.tsx:120 -#: assets/pages/LoginPage.tsx:40 +#: assets/pages/LoginPage.tsx:49 msgid "Log in" msgstr "" @@ -434,7 +434,7 @@ msgid "" "their country of origin." msgstr "" -#: assets/pages/LoginPage.tsx:60 +#: assets/pages/LoginPage.tsx:69 #: assets/pages/watchdog/UserPage.tsx:18 msgid "Username" msgstr "" @@ -463,19 +463,19 @@ msgstr "" msgid "Sorry, the page you visited does not exist." msgstr "" -#: assets/pages/LoginPage.tsx:45 +#: assets/pages/LoginPage.tsx:54 msgid "Error" msgstr "" -#: assets/pages/LoginPage.tsx:68 +#: assets/pages/LoginPage.tsx:77 msgid "Password" msgstr "" -#: assets/pages/LoginPage.tsx:77 +#: assets/pages/LoginPage.tsx:86 msgid "Submit" msgstr "" -#: assets/pages/LoginPage.tsx:82 +#: assets/pages/LoginPage.tsx:91 msgid "Log in with SSO" msgstr "" @@ -531,7 +531,7 @@ msgstr "" msgid "Documentation" msgstr "" -#: assets/App.tsx:106 +#: assets/App.tsx:107 #, javascript-format msgid "" "${ ProjectLink } is an open source project distributed under the ${ "