diff options
| author | dkanada <dkanada@users.noreply.github.com> | 2021-02-17 11:49:59 +0900 |
|---|---|---|
| committer | Joshua M. Boniface <joshua@boniface.me> | 2021-02-21 13:30:32 -0500 |
| commit | a1773ce97bc507ee6372d96519d5993cd8c52636 (patch) | |
| tree | a6fd287c4470bf1389ef3bce5ad182cdee3b8f9c | |
| parent | be7411dc58d4f88b74175463adec361a330596bc (diff) | |
Merge pull request #5250 from barronpm/user-rename-fix
Fix user renaming logic
(cherry picked from commit b4c2086138cf51be0df6c116533de78ed08fc7d2)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
| -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 1f3f2a496..854912ba8 100644 --- a/Jellyfin.Server.Implementations/Users/UserManager.cs +++ b/Jellyfin.Server.Implementations/Users/UserManager.cs @@ -148,7 +148,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, @@ -207,6 +207,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); |
