From 636dcb984f042ae98f829494f94d5bdc00f42163 Mon Sep 17 00:00:00 2001 From: Geoffrey Coulaud Date: Thu, 12 Mar 2026 15:46:59 +0000 Subject: [PATCH] feat: add trailing whitespace warning on login username field (#2040) (#2177) --- src/components/Login/JellyfinLogin.tsx | 12 +++++++++++- src/components/Login/LocalLogin.tsx | 12 +++++++++++- src/i18n/locale/en.json | 2 ++ src/styles/globals.css | 4 ++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/components/Login/JellyfinLogin.tsx b/src/components/Login/JellyfinLogin.tsx index 41fc9b6e..f241bb66 100644 --- a/src/components/Login/JellyfinLogin.tsx +++ b/src/components/Login/JellyfinLogin.tsx @@ -3,6 +3,7 @@ import SensitiveInput from '@app/components/Common/SensitiveInput'; import useSettings from '@app/hooks/useSettings'; import defineMessages from '@app/utils/defineMessages'; import { ArrowLeftOnRectangleIcon } from '@heroicons/react/24/outline'; +import { ExclamationTriangleIcon } from '@heroicons/react/24/solid'; import { ApiErrorCode } from '@server/constants/error'; import { MediaServerType, ServerType } from '@server/constants/server'; import axios from 'axios'; @@ -22,6 +23,7 @@ const messages = defineMessages('components.Login', { noadminerror: 'No admin user found on the server.', credentialerror: 'The username or password is incorrect.', invalidurlerror: 'Unable to connect to {mediaServerName} server.', + tipUsernameHasTrailingWhitespace: 'The username ends with whitespace', signingin: 'Signing In…', signin: 'Sign In', forgotpassword: 'Forgot Password?', @@ -108,7 +110,7 @@ const JellyfinLogin: React.FC = ({ } }} > - {({ errors, touched, isSubmitting, isValid }) => { + {({ errors, touched, values, isSubmitting, isValid }) => { return ( <>
@@ -130,6 +132,14 @@ const JellyfinLogin: React.FC = ({ data-form-type="username" /> + {touched.username && values.username.match(/\s$/) && ( +
+ + {intl.formatMessage( + messages.tipUsernameHasTrailingWhitespace + )} +
+ )} {errors.username && touched.username && (
{errors.username}
)} diff --git a/src/components/Login/LocalLogin.tsx b/src/components/Login/LocalLogin.tsx index e24418cd..f7f52452 100644 --- a/src/components/Login/LocalLogin.tsx +++ b/src/components/Login/LocalLogin.tsx @@ -3,6 +3,7 @@ import SensitiveInput from '@app/components/Common/SensitiveInput'; import useSettings from '@app/hooks/useSettings'; import defineMessages from '@app/utils/defineMessages'; import { ArrowLeftOnRectangleIcon } from '@heroicons/react/24/outline'; +import { ExclamationTriangleIcon } from '@heroicons/react/24/solid'; import axios from 'axios'; import { Field, Form, Formik } from 'formik'; import Link from 'next/link'; @@ -18,6 +19,7 @@ const messages = defineMessages('components.Login', { validationemailrequired: 'You must provide a valid email address', validationpasswordrequired: 'You must provide a password', loginerror: 'Something went wrong while trying to sign in.', + tipEmailHasTrailingWhitespace: 'The email ends with whitespace', signingin: 'Signing In…', signin: 'Sign In', forgotpassword: 'Forgot Password?', @@ -66,7 +68,7 @@ const LocalLogin = ({ revalidate }: LocalLoginProps) => { } }} > - {({ errors, touched, isSubmitting, isValid }) => { + {({ errors, touched, values, isSubmitting, isValid }) => { return ( <> @@ -92,6 +94,14 @@ const LocalLogin = ({ revalidate }: LocalLoginProps) => { className="!bg-gray-700/80 placeholder:text-gray-400" /> + {touched.email && values.email.match(/\s$/) && ( +
+ + {intl.formatMessage( + messages.tipEmailHasTrailingWhitespace + )} +
+ )} {errors.email && touched.email && typeof errors.email === 'string' && ( diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 06ad3fec..b8769445 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -269,6 +269,8 @@ "components.Login.signinwithjellyfin": "Use your {mediaServerName} account", "components.Login.signinwithoverseerr": "Use your {applicationTitle} account", "components.Login.signinwithplex": "Use your Plex account", + "components.Login.tipEmailHasTrailingWhitespace": "The email ends with whitespace", + "components.Login.tipUsernameHasTrailingWhitespace": "The username ends with whitespace", "components.Login.title": "Add Email", "components.Login.urlBase": "URL Base", "components.Login.username": "Username", diff --git a/src/styles/globals.css b/src/styles/globals.css index 92a6b146..00793a42 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -382,6 +382,10 @@ @apply mt-2 text-sm text-red-500; } + .warning { + @apply mt-2 text-sm text-yellow-500; + } + .form-group { @apply mt-6 text-white; }