Apply suggestions from code review

Co-Authored-By: Claus Vium <cvium@users.noreply.github.com>
Co-Authored-By: Bond-009 <bond.009@outlook.com>
This commit is contained in:
Joshua M. Boniface 2019-06-09 13:41:14 -04:00 committed by GitHub
parent 74ef389879
commit b70083f3b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -9,7 +9,7 @@ namespace Emby.Server.Implementations.Library
{ {
public class InvalidAuthProvider : IAuthenticationProvider public class InvalidAuthProvider : IAuthenticationProvider
{ {
public string Name => "InvalidorMissingAuthenticationProvider"; public string Name => "InvalidOrMissingAuthenticationProvider";
public bool IsEnabled => true; public bool IsEnabled => true;
@ -25,7 +25,7 @@ namespace Emby.Server.Implementations.Library
public Task ChangePassword(User user, string newPassword) public Task ChangePassword(User user, string newPassword)
{ {
return Task.FromResult(true); return Task.CompletedTask;
} }
public void ChangeEasyPassword(User user, string newPassword, string newPasswordHash) public void ChangeEasyPassword(User user, string newPassword, string newPasswordHash)
@ -35,12 +35,12 @@ namespace Emby.Server.Implementations.Library
public string GetPasswordHash(User user) public string GetPasswordHash(User user)
{ {
return ""; return string.Empty;
} }
public string GetEasyPasswordHash(User user) public string GetEasyPasswordHash(User user)
{ {
return ""; return string.Empty;
} }
} }
} }

View file

@ -313,8 +313,7 @@ namespace Emby.Server.Implementations.Library
if (authenticationProvider.GetType() != typeof(InvalidAuthProvider)) if (authenticationProvider.GetType() != typeof(InvalidAuthProvider))
{ {
var hasNewUserPolicy = authenticationProvider as IHasNewUserPolicy; if (authenticationProvider is IHasNewUserPolicy hasNewUserPolicy)
if (hasNewUserPolicy != null)
{ {
var policy = hasNewUserPolicy.GetNewUserPolicy(); var policy = hasNewUserPolicy.GetNewUserPolicy();
UpdateUserPolicy(user, policy, true); UpdateUserPolicy(user, policy, true);
@ -408,7 +407,7 @@ namespace Emby.Server.Implementations.Library
if (providers.Length == 0) if (providers.Length == 0)
{ {
// Assign the user to the InvalidAuthProvider since no configured auth provider was valid/found // Assign the user to the InvalidAuthProvider since no configured auth provider was valid/found
_logger.LogWarning("User {0} was found with invalid/missing Authentication Provider {1}. Assigning user to InvalidAuthProvider until this is corrected", user.Name, user.Policy.AuthenticationProviderId); _logger.LogWarning("User {UserName} was found with invalid/missing Authentication Provider {AuthenticationProviderId}. Assigning user to InvalidAuthProvider until this is corrected", user.Name, user.Policy.AuthenticationProviderId);
providers = new IAuthenticationProvider[] { _invalidAuthProvider }; providers = new IAuthenticationProvider[] { _invalidAuthProvider };
} }