aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/User/UserManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Server.Implementations/User/UserManager.cs')
-rw-r--r--Jellyfin.Server.Implementations/User/UserManager.cs22
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,