Merge pull request #3727 from K900/patch-1

Fix #3624
This commit is contained in:
Anthony Lavado 2020-07-31 08:26:59 -07:00 committed by GitHub
commit 06db5f8bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -600,18 +600,13 @@ namespace Jellyfin.Server.Implementations.Users
}
var defaultName = Environment.UserName;
if (string.IsNullOrWhiteSpace(defaultName))
if (string.IsNullOrWhiteSpace(defaultName) || !IsValidUsername(defaultName))
{
defaultName = "MyJellyfinUser";
}
_logger.LogWarning("No users, creating one with username {UserName}", defaultName);
if (!IsValidUsername(defaultName))
{
throw new ArgumentException("Provided username is not valid!", defaultName);
}
var newUser = await CreateUserInternalAsync(defaultName, dbContext).ConfigureAwait(false);
newUser.SetPermission(PermissionKind.IsAdministrator, true);
newUser.SetPermission(PermissionKind.EnableContentDeletion, true);