diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs b/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs index 0ac9d33c4..1e484b237 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs @@ -88,6 +88,12 @@ namespace Ombi.Schedule.Jobs.Plex _log.LogInformation("Could not create Plex user since the have no username, PlexUserId: {0}", plexUser.Id); continue; } + + if ((plexUser.Email.HasValue()) && await _userManager.FindByEmailAsync(plexUser.Email) != null) + { + _log.LogWarning($"Cannot add user {plexUser.Username} because their email address is already in Ombi, skipping this user"); + continue; + } // Create this users // We do not store a password against the user since they will authenticate via Plex var newUser = new OmbiUser diff --git a/src/Ombi/Controllers/V1/IdentityController.cs b/src/Ombi/Controllers/V1/IdentityController.cs index 500cd4610..63f8211ca 100644 --- a/src/Ombi/Controllers/V1/IdentityController.cs +++ b/src/Ombi/Controllers/V1/IdentityController.cs @@ -457,6 +457,10 @@ namespace Ombi.Controllers.V1 { return Error("You do not have the correct permissions to create this user"); } + if(user.EmailAddress.HasValue() && await UserManager.FindByEmailAsync(user.EmailAddress) != null) + { + return Error("This email has already been taken"); + } var ombiUser = new OmbiUser { Alias = user.Alias,