diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2019-06-12 23:30:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-12 23:30:57 -0400 |
| commit | 687255aa318cb99d90304bb490d04e6becfc54dd (patch) | |
| tree | 9b7182bf461cd50b2fd76393f7591f7278e42b5b /Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs | |
| parent | e3a3aebbf69855f527b7150304d83ca9abc955ff (diff) | |
| parent | d5fe82314e11d3b8b2ba58e4684a7968fbe6dbca (diff) | |
Merge pull request #1442 from jellyfin/release-10.3.z
Backmerge for Release 10.3.4 and 10.3.5
Diffstat (limited to 'Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs index 0527464ff..fe09b07ff 100644 --- a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs +++ b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs @@ -165,6 +165,34 @@ namespace Emby.Server.Implementations.Library return user.Password; } + public void ChangeEasyPassword(User user, string newPassword, string newPasswordHash) + { + ConvertPasswordFormat(user); + + if (newPassword != null) + { + newPasswordHash = string.Format("$SHA1${0}", GetHashedString(user, newPassword)); + } + + if (string.IsNullOrWhiteSpace(newPasswordHash)) + { + throw new ArgumentNullException(nameof(newPasswordHash)); + } + + user.EasyPassword = newPasswordHash; + } + + public string GetEasyPasswordHash(User user) + { + // This should be removed in the future. This was added to let user login after + // Jellyfin 10.3.3 failed to save a well formatted PIN. + ConvertPasswordFormat(user); + + return string.IsNullOrEmpty(user.EasyPassword) + ? null + : (new PasswordHash(user.EasyPassword)).Hash; + } + public string GetHashedStringChangeAuth(string newPassword, PasswordHash passwordHash) { passwordHash.HashBytes = Encoding.UTF8.GetBytes(newPassword); |
