Merge pull request #3533 from barronpm/user-login-casing

Make User Authentication Case-insensitive and remove EF Core Log spam
This commit is contained in:
Joshua M. Boniface 2020-07-12 19:32:51 -04:00 committed by GitHub
commit 29a386ee2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -296,7 +296,7 @@ namespace Emby.Server.Implementations.Session
} }
catch (DbUpdateConcurrencyException e) catch (DbUpdateConcurrencyException e)
{ {
_logger.LogWarning(e, "Error updating user's last activity date."); _logger.LogDebug(e, "Error updating user's last activity date.");
} }
} }
} }

View File

@ -110,9 +110,8 @@ namespace Jellyfin.Server.Implementations.Users
throw new ArgumentException("Invalid username", nameof(name)); throw new ArgumentException("Invalid username", nameof(name));
} }
// This can't use an overload with StringComparer because that would cause the query to return _dbProvider.CreateContext().Users.AsEnumerable()
// have to be evaluated client-side. .FirstOrDefault(u => string.Equals(u.Username, name, StringComparison.OrdinalIgnoreCase));
return _dbProvider.CreateContext().Users.FirstOrDefault(u => string.Equals(u.Username, name));
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -381,7 +380,7 @@ namespace Jellyfin.Server.Implementations.Users
throw new ArgumentNullException(nameof(username)); throw new ArgumentNullException(nameof(username));
} }
var user = Users.ToList().FirstOrDefault(i => string.Equals(username, i.Username, StringComparison.OrdinalIgnoreCase)); var user = Users.AsEnumerable().FirstOrDefault(i => string.Equals(username, i.Username, StringComparison.OrdinalIgnoreCase));
bool success; bool success;
IAuthenticationProvider? authenticationProvider; IAuthenticationProvider? authenticationProvider;
@ -409,8 +408,7 @@ namespace Jellyfin.Server.Implementations.Users
// Search the database for the user again // Search the database for the user again
// the authentication provider might have created it // the authentication provider might have created it
user = Users user = Users.AsEnumerable().FirstOrDefault(i => string.Equals(username, i.Username, StringComparison.OrdinalIgnoreCase));
.ToList().FirstOrDefault(i => string.Equals(username, i.Username, StringComparison.OrdinalIgnoreCase));
if (authenticationProvider is IHasNewUserPolicy hasNewUserPolicy) if (authenticationProvider is IHasNewUserPolicy hasNewUserPolicy)
{ {