diff options
| author | Patrick Barron <barronpm@gmail.com> | 2021-02-16 20:48:41 -0500 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2021-02-16 20:48:41 -0500 |
| commit | f127096660a0eed7da2ef6db68720eba4dfbd7a0 (patch) | |
| tree | cdb3084cb0871f100496479a93f93a319f397cad /Jellyfin.Server.Implementations/Users/UserManager.cs | |
| parent | 1171b5ab923e0a0ad6b412201ed7ba0d33f51229 (diff) | |
Don't allow new users to be created with the same name as an existing user.
Diffstat (limited to 'Jellyfin.Server.Implementations/Users/UserManager.cs')
| -rw-r--r-- | Jellyfin.Server.Implementations/Users/UserManager.cs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs index 95736c37f..a3a9e90d4 100644 --- a/Jellyfin.Server.Implementations/Users/UserManager.cs +++ b/Jellyfin.Server.Implementations/Users/UserManager.cs @@ -206,6 +206,14 @@ namespace Jellyfin.Server.Implementations.Users throw new ArgumentException("Usernames can contain unicode symbols, numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)"); } + if (Users.Any(u => u.Username.Equals(name, StringComparison.OrdinalIgnoreCase))) + { + throw new ArgumentException(string.Format( + CultureInfo.InvariantCulture, + "A user with the name '{0}' already exists.", + name)); + } + await using var dbContext = _dbProvider.CreateContext(); var newUser = await CreateUserInternalAsync(name, dbContext).ConfigureAwait(false); |
