IUserManager.cs 7.7 KB

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