diff options
| author | dkanada <dkanada@users.noreply.github.com> | 2021-02-17 11:49:59 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-17 11:49:59 +0900 |
| commit | b4c2086138cf51be0df6c116533de78ed08fc7d2 (patch) | |
| tree | 5c4925516326564d41bfc8561bc44319d771c11f | |
| parent | 1e2ce4e6987a80c2b54cc1a2c0687c29de600427 (diff) | |
| parent | f127096660a0eed7da2ef6db68720eba4dfbd7a0 (diff) | |
Merge pull request #5250 from barronpm/user-rename-fix
Fix user renaming logic
| -rw-r--r-- | Jellyfin.Server.Implementations/Users/UserManager.cs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs index d1de5408c..a3a9e90d4 100644 --- a/Jellyfin.Server.Implementations/Users/UserManager.cs +++ b/Jellyfin.Server.Implementations/Users/UserManager.cs @@ -147,7 +147,7 @@ namespace Jellyfin.Server.Implementations.Users throw new ArgumentException("The new and old names must be different."); } - if (Users.Any(u => u.Id != user.Id && u.Username.Equals(newName, StringComparison.Ordinal))) + if (Users.Any(u => u.Id != user.Id && u.Username.Equals(newName, StringComparison.OrdinalIgnoreCase))) { throw new ArgumentException(string.Format( CultureInfo.InvariantCulture, @@ -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); |
