mirror of
https://github.com/seerr-team/seerr.git
synced 2026-05-23 16:28:49 -04:00
fix: normalize email addresses from IDP before lookup / storage
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user