diff options
| author | Patrick Barron <barronpm@gmail.com> | 2020-05-12 22:25:45 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-05-13 00:00:57 -0400 |
| commit | b7621d762c58320b35096838ae8ab10d98ea9bb2 (patch) | |
| tree | 895708bda08c4831a8e30e7b0ea7ca7d67da88b8 /Jellyfin.Server.Implementations/User/UserManager.cs | |
| parent | c1360a1dc312938e77e52a509eb9186300bcb40d (diff) | |
| parent | bac4bf96a0e642f80f35bd6cdf3de17a9302b6c6 (diff) | |
2nd half of changes
Diffstat (limited to 'Jellyfin.Server.Implementations/User/UserManager.cs')
| -rw-r--r-- | Jellyfin.Server.Implementations/User/UserManager.cs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Jellyfin.Server.Implementations/User/UserManager.cs b/Jellyfin.Server.Implementations/User/UserManager.cs index 1ed11cfcb..73905ff70 100644 --- a/Jellyfin.Server.Implementations/User/UserManager.cs +++ b/Jellyfin.Server.Implementations/User/UserManager.cs @@ -306,6 +306,28 @@ namespace Jellyfin.Server.Implementations.User }; } + public PublicUserDto GetPublicUserDto(Data.Entities.User user, string remoteEndPoint = null) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + + bool hasConfiguredPassword = GetAuthenticationProvider(user).HasPassword(user); + bool hasConfiguredEasyPassword = !string.IsNullOrEmpty(GetAuthenticationProvider(user).GetEasyPasswordHash(user)); + + bool hasPassword = user.EnableLocalPassword && + !string.IsNullOrEmpty(remoteEndPoint) && + _networkManager.IsInLocalNetwork(remoteEndPoint) ? hasConfiguredEasyPassword : hasConfiguredPassword; + + return new PublicUserDto + { + Name = user.Username, + HasPassword = hasPassword, + HasConfiguredPassword = hasConfiguredPassword + }; + } + public async Task<Data.Entities.User> AuthenticateUser( string username, string password, |
