Skip to content

Commit

Permalink
fix: disallow Plex users from changing their email
Browse files Browse the repository at this point in the history
  • Loading branch information
gauthier-th committed Jul 29, 2024
1 parent b5775f9 commit 86ba7d5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
14 changes: 13 additions & 1 deletion server/routes/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ router.get('/', async (req, res, next) => {
break;
case 'displayname':
query = query.orderBy(
"(CASE WHEN (user.username IS NULL OR user.username = '') THEN (CASE WHEN (user.plexUsername IS NULL OR user.plexUsername = '') THEN user.email ELSE LOWER(user.plexUsername) END) ELSE LOWER(user.username) END)",
`CASE WHEN (user.username IS NULL OR user.username = '') THEN (
CASE WHEN (user.plexUsername IS NULL OR user.plexUsername = '') THEN (
CASE WHEN (user.jellyfinUsername IS NULL OR user.jellyfinUsername = '') THEN
user.email
ELSE
LOWER(user.jellyfinUsername)
END)
ELSE
LOWER(user.jellyfinUsername)
END)
ELSE
LOWER(user.username)
END`,
'ASC'
);
break;
Expand Down
6 changes: 3 additions & 3 deletions server/routes/user/usersettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ userSettingsRoutes.post<
}

user.username = req.body.username;
user.email =
req.body.email ||
((user.plexUsername || user.jellyfinUsername) as string);
if (user.jellyfinUsername) {
user.email = req.body.email || user.jellyfinUsername || user.email;
}

// Update quota values only if the user has the correct permissions
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ const UserGeneralSettings = () => {
name="email"
type="text"
placeholder="[email protected]"
disabled={user?.plexUsername}
className={
user?.warnings.find((w) => w === 'userEmailRequired')
? 'border-2 border-red-400 focus:border-blue-600'
Expand Down

0 comments on commit 86ba7d5

Please sign in to comment.