fix: add email requirement for local users (#1389)

* fix: add email requirement for local users

Because of a misunderstanding, and the requirement to have a mandatory email for local users was
removed, when it shouldn't have been.

re #900
fix #1367

* fix: add missing check for Emby
This commit is contained in:
Gauthier
2025-02-23 11:25:25 +01:00
committed by GitHub
parent a3f4773a35
commit f0a6055774
3 changed files with 8 additions and 21 deletions

View File

@@ -119,28 +119,10 @@ userSettingsRoutes.post<
}
const oldEmail = user.email;
const oldUsername = user.username;
user.username = req.body.username;
if (user.jellyfinUsername) {
if (user.userType !== UserType.PLEX) {
user.email = req.body.email || user.jellyfinUsername || user.email;
}
// Edge case for local users, because they have no Jellyfin username to fall back on
// if the email is not provided
if (user.userType === UserType.LOCAL) {
if (req.body.email) {
user.email = req.body.email;
if (
!user.username &&
user.email !== oldEmail &&
!oldEmail.includes('@')
) {
user.username = oldEmail;
}
} else if (req.body.username) {
user.email = oldUsername || user.email;
user.username = req.body.username;
}
}
const existingUser = await userRepository.findOne({
where: { email: user.email },

View File

@@ -210,7 +210,9 @@ const UserList = () => {
username: Yup.string().required(
intl.formatMessage(messages.validationUsername)
),
email: Yup.string().email(intl.formatMessage(messages.validationEmail)),
email: Yup.string()
.required()
.email(intl.formatMessage(messages.validationEmail)),
password: Yup.lazy((value) =>
!value
? Yup.string()
@@ -388,6 +390,7 @@ const UserList = () => {
<div className="form-row">
<label htmlFor="email" className="text-label">
{intl.formatMessage(messages.email)}
<span className="label-required">*</span>
</label>
<div className="form-input-area">
<div className="form-input-field">

View File

@@ -100,7 +100,9 @@ const UserGeneralSettings = () => {
const UserGeneralSettingsSchema = Yup.object().shape({
email:
user?.id === 1
// email is required for everybody except non-admin jellyfin users
user?.id === 1 ||
(user?.userType !== UserType.JELLYFIN && user?.userType !== UserType.EMBY)
? Yup.string()
.email(intl.formatMessage(messages.validationemailformat))
.required(intl.formatMessage(messages.validationemailrequired))