mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Don't allow new users to be created with the same name as an existing user.
This commit is contained in:
parent
1171b5ab92
commit
f127096660
@ -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 (.)");
|
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();
|
await using var dbContext = _dbProvider.CreateContext();
|
||||||
|
|
||||||
var newUser = await CreateUserInternalAsync(name, dbContext).ConfigureAwait(false);
|
var newUser = await CreateUserInternalAsync(name, dbContext).ConfigureAwait(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user