From 136157cdf9d01d521dd0f48c56b9902eafddcfef Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Fri, 27 Mar 2026 13:08:15 -0400 Subject: [PATCH] fix: normalize email addresses from IDP before lookup / storage --- server/routes/auth.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/routes/auth.ts b/server/routes/auth.ts index babdaf0fe..657e37448 100644 --- a/server/routes/auth.ts +++ b/server/routes/auth.ts @@ -947,9 +947,11 @@ authRoutes.post( // Create user if one doesn't already exist if (!user && fullUserInfo.email != null && provider.newUserLogin) { + const normalizedEmail = fullUserInfo.email.trim().toLowerCase(); + // Check if a user with this email already exists const existingUser = await userRepository.findOne({ - where: { email: fullUserInfo.email }, + where: { email: normalizedEmail }, }); if (existingUser) { @@ -959,19 +961,19 @@ authRoutes.post( }); } - logger.info(`Creating user for ${fullUserInfo.email}`, { + logger.info(`Creating user for ${normalizedEmail}`, { ip: req.ip, - email: fullUserInfo.email, + email: normalizedEmail, }); const avatar = fullUserInfo.picture ?? - gravatarUrl(fullUserInfo.email, { default: 'mm', size: 200 }); + gravatarUrl(normalizedEmail, { default: 'mm', size: 200 }); user = new User({ avatar: avatar, username: fullUserInfo.preferred_username, - email: fullUserInfo.email, + email: normalizedEmail, permissions: settings.main.defaultPermissions, plexToken: '', userType: UserType.LOCAL,