2
0

IUserManager.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. using Jellyfin.Data.Entities;
  6. using Jellyfin.Data.Events;
  7. using MediaBrowser.Model.Configuration;
  8. using MediaBrowser.Model.Dto;
  9. using MediaBrowser.Model.Users;
  10. namespace MediaBrowser.Controller.Library
  11. {
  12. /// <summary>
  13. /// Interface IUserManager.
  14. /// </summary>
  15. public interface IUserManager
  16. {
  17. /// <summary>
  18. /// Occurs when a user is updated.
  19. /// </summary>
  20. event EventHandler<GenericEventArgs<User>> OnUserUpdated;
  21. /// <summary>
  22. /// Gets the users.
  23. /// </summary>
  24. /// <value>The users.</value>
  25. IEnumerable<User> Users { get; }
  26. /// <summary>
  27. /// Gets the user ids.
  28. /// </summary>
  29. /// <value>The users ids.</value>
  30. IEnumerable<Guid> UsersIds { get; }
  31. /// <summary>
  32. /// Initializes the user manager and ensures that a user exists.
  33. /// </summary>
  34. /// <returns>Awaitable task.</returns>
  35. Task InitializeAsync();
  36. /// <summary>
  37. /// Gets a user by Id.
  38. /// </summary>
  39. /// <param name="id">The id.</param>
  40. /// <returns>The user with the specified Id, or <c>null</c> if the user doesn't exist.</returns>
  41. /// <exception cref="ArgumentException"><c>id</c> is an empty Guid.</exception>
  42. User? GetUserById(Guid id);
  43. /// <summary>
  44. /// Gets the name of the user by.
  45. /// </summary>
  46. /// <param name="name">The name.</param>
  47. /// <returns>User.</returns>
  48. User? GetUserByName(string name);
  49. /// <summary>
  50. /// Renames the user.
  51. /// </summary>
  52. /// <param name="user">The user.</param>
  53. /// <param name="newName">The new name.</param>
  54. /// <returns>Task.</returns>
  55. /// <exception cref="ArgumentNullException">If user is <c>null</c>.</exception>
  56. /// <exception cref="ArgumentException">If the provided user doesn't exist.</exception>
  57. Task RenameUser(User user, string newName);
  58. /// <summary>
  59. /// Updates the user.
  60. /// </summary>
  61. /// <param name="user">The user.</param>
  62. /// <exception cref="ArgumentNullException">If user is <c>null</c>.</exception>
  63. /// <exception cref="ArgumentException">If the provided user doesn't exist.</exception>
  64. /// <returns>A task representing the update of the user.</returns>
  65. Task UpdateUserAsync(User user);
  66. /// <summary>
  67. /// Creates a user with the specified name.
  68. /// </summary>
  69. /// <param name="name">The name of the new user.</param>
  70. /// <returns>The created user.</returns>
  71. /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
  72. /// <exception cref="ArgumentException"><paramref name="name"/> already exists.</exception>
  73. Task<User> CreateUserAsync(string name);
  74. /// <summary>
  75. /// Deletes the specified user.
  76. /// </summary>
  77. /// <param name="userId">The id of the user to be deleted.</param>
  78. /// <returns>A task representing the deletion of the user.</returns>
  79. Task DeleteUserAsync(Guid userId);
  80. /// <summary>
  81. /// Resets the password.
  82. /// </summary>
  83. /// <param name="user">The user.</param>
  84. /// <returns>Task.</returns>
  85. Task ResetPassword(User user);
  86. /// <summary>
  87. /// Changes the password.
  88. /// </summary>
  89. /// <param name="user">The user.</param>
  90. /// <param name="newPassword">New password to use.</param>
  91. /// <returns>Awaitable task.</returns>
  92. Task ChangePassword(User user, string newPassword);
  93. /// <summary>
  94. /// Gets the user dto.
  95. /// </summary>
  96. /// <param name="user">The user.</param>
  97. /// <param name="remoteEndPoint">The remote end point.</param>
  98. /// <returns>UserDto.</returns>
  99. UserDto GetUserDto(User user, string? remoteEndPoint = null);
  100. /// <summary>
  101. /// Authenticates the user.
  102. /// </summary>
  103. /// <param name="username">The user.</param>
  104. /// <param name="password">The password to use.</param>
  105. /// <param name="remoteEndPoint">Remove endpoint to use.</param>
  106. /// <param name="isUserSession">Specifies if a user session.</param>
  107. /// <returns>User wrapped in awaitable task.</returns>
  108. Task<User?> AuthenticateUser(string username, string password, string remoteEndPoint, bool isUserSession);
  109. /// <summary>
  110. /// Starts the forgot password process.
  111. /// </summary>
  112. /// <param name="enteredUsername">The entered username.</param>
  113. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  114. /// <returns>ForgotPasswordResult.</returns>
  115. Task<ForgotPasswordResult> StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  116. /// <summary>
  117. /// Redeems the password reset pin.
  118. /// </summary>
  119. /// <param name="pin">The pin.</param>
  120. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  121. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  122. NameIdPair[] GetAuthenticationProviders();
  123. NameIdPair[] GetPasswordResetProviders();
  124. /// <summary>
  125. /// This method updates the user's configuration.
  126. /// This is only included as a stopgap until the new API, using this internally is not recommended.
  127. /// Instead, modify the user object directly, then call <see cref="UpdateUserAsync"/>.
  128. /// </summary>
  129. /// <param name="userId">The user's Id.</param>
  130. /// <param name="config">The request containing the new user configuration.</param>
  131. /// <returns>A task representing the update.</returns>
  132. Task UpdateConfigurationAsync(Guid userId, UserConfiguration config);
  133. /// <summary>
  134. /// This method updates the user's policy.
  135. /// This is only included as a stopgap until the new API, using this internally is not recommended.
  136. /// Instead, modify the user object directly, then call <see cref="UpdateUserAsync"/>.
  137. /// </summary>
  138. /// <param name="userId">The user's Id.</param>
  139. /// <param name="policy">The request containing the new user policy.</param>
  140. /// <returns>A task representing the update.</returns>
  141. Task UpdatePolicyAsync(Guid userId, UserPolicy policy);
  142. /// <summary>
  143. /// Clears the user's profile image.
  144. /// </summary>
  145. /// <param name="user">The user.</param>
  146. /// <returns>A task representing the clearing of the profile image.</returns>
  147. Task ClearProfileImageAsync(User user);
  148. }
  149. }