mirror of https://github.com/jellyfin/jellyfin.git
Minor fixes to address style issues
This commit is contained in:
parent
2c26517172
commit
bef665be36
|
@ -50,22 +50,22 @@ namespace Emby.Server.Implementations.Library
|
||||||
byte[] passwordbytes = Encoding.UTF8.GetBytes(password);
|
byte[] passwordbytes = Encoding.UTF8.GetBytes(password);
|
||||||
|
|
||||||
PasswordHash readyHash = new PasswordHash(resolvedUser.Password);
|
PasswordHash readyHash = new PasswordHash(resolvedUser.Password);
|
||||||
byte[] CalculatedHash;
|
byte[] calculatedHash;
|
||||||
string CalculatedHashString;
|
string calculatedHashString;
|
||||||
if (_cryptographyProvider.GetSupportedHashMethods().Contains(readyHash.Id))
|
if (_cryptographyProvider.GetSupportedHashMethods().Contains(readyHash.Id))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(readyHash.Salt))
|
if (string.IsNullOrEmpty(readyHash.Salt))
|
||||||
{
|
{
|
||||||
CalculatedHash = _cryptographyProvider.ComputeHash(readyHash.Id, passwordbytes);
|
calculatedHash = _cryptographyProvider.ComputeHash(readyHash.Id, passwordbytes);
|
||||||
CalculatedHashString = BitConverter.ToString(CalculatedHash).Replace("-", string.Empty);
|
calculatedHashString = BitConverter.ToString(calculatedHash).Replace("-", string.Empty);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CalculatedHash = _cryptographyProvider.ComputeHash(readyHash.Id, passwordbytes, readyHash.SaltBytes);
|
calculatedHash = _cryptographyProvider.ComputeHash(readyHash.Id, passwordbytes, readyHash.SaltBytes);
|
||||||
CalculatedHashString = BitConverter.ToString(CalculatedHash).Replace("-", string.Empty);
|
calculatedHashString = BitConverter.ToString(calculatedHash).Replace("-", string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CalculatedHashString == readyHash.Hash)
|
if (calculatedHashString == readyHash.Hash)
|
||||||
{
|
{
|
||||||
success = true;
|
success = true;
|
||||||
// throw new Exception("Invalid username or password");
|
// throw new Exception("Invalid username or password");
|
||||||
|
|
|
@ -475,11 +475,6 @@ namespace Emby.Server.Implementations.Library
|
||||||
: user.EasyPassword;
|
: user.EasyPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsPasswordEmpty(User user, string passwordHash)
|
|
||||||
{
|
|
||||||
return string.IsNullOrEmpty(passwordHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the users from the repository
|
/// Loads the users from the repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -522,14 +517,14 @@ namespace Emby.Server.Implementations.Library
|
||||||
throw new ArgumentNullException(nameof(user));
|
throw new ArgumentNullException(nameof(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasConfiguredPassword = GetAuthenticationProvider(user).HasPassword(user).Result;
|
bool hasConfiguredPassword = GetAuthenticationProvider(user).HasPassword(user).Result;
|
||||||
var hasConfiguredEasyPassword = !IsPasswordEmpty(user, GetLocalPasswordHash(user));
|
bool hasConfiguredEasyPassword = string.IsNullOrEmpty(GetLocalPasswordHash(user));
|
||||||
|
|
||||||
var hasPassword = user.Configuration.EnableLocalPassword && !string.IsNullOrEmpty(remoteEndPoint) && _networkManager.IsInLocalNetwork(remoteEndPoint) ?
|
bool hasPassword = user.Configuration.EnableLocalPassword && !string.IsNullOrEmpty(remoteEndPoint) && _networkManager.IsInLocalNetwork(remoteEndPoint) ?
|
||||||
hasConfiguredEasyPassword :
|
hasConfiguredEasyPassword :
|
||||||
hasConfiguredPassword;
|
hasConfiguredPassword;
|
||||||
|
|
||||||
var dto = new UserDto
|
UserDto dto = new UserDto
|
||||||
{
|
{
|
||||||
Id = user.Id,
|
Id = user.Id,
|
||||||
Name = user.Name,
|
Name = user.Name,
|
||||||
|
@ -548,7 +543,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
dto.EnableAutoLogin = true;
|
dto.EnableAutoLogin = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var image = user.GetImageInfo(ImageType.Primary, 0);
|
ItemImageInfo image = user.GetImageInfo(ImageType.Primary, 0);
|
||||||
|
|
||||||
if (image != null)
|
if (image != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,13 +100,14 @@ namespace MediaBrowser.Model.Cryptography
|
||||||
|
|
||||||
public static byte[] ConvertFromByteString(string byteString)
|
public static byte[] ConvertFromByteString(string byteString)
|
||||||
{
|
{
|
||||||
List<byte> Bytes = new List<byte>();
|
List<byte> bytes = new List<byte>();
|
||||||
for (int i = 0; i < byteString.Length; i += 2)
|
for (int i = 0; i < byteString.Length; i += 2)
|
||||||
{
|
{
|
||||||
Bytes.Add(Convert.ToByte(byteString.Substring(i, 2),16));
|
// TODO: NetStandard2.1 switch this to use a span instead of a substring.
|
||||||
|
bytes.Add(Convert.ToByte(byteString.Substring(i, 2),16));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Bytes.ToArray();
|
return bytes.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ConvertToByteString(byte[] bytes)
|
public static string ConvertToByteString(byte[] bytes)
|
||||||
|
|
Loading…
Reference in New Issue