IUserManager.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. /// <returns>A task representing the update of the user.</returns>
  66. Task UpdateUserAsync(User user);
  67. /// <summary>
  68. /// Creates a user with the specified name.
  69. /// </summary>
  70. /// <param name="name">The name of the new user.</param>
  71. /// <returns>The created user.</returns>
  72. /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
  73. /// <exception cref="ArgumentException"><paramref name="name"/> already exists.</exception>
  74. Task<User> CreateUserAsync(string name);
  75. /// <summary>
  76. /// Deletes the specified user.
  77. /// </summary>
  78. /// <param name="userId">The id of the user to be deleted.</param>
  79. /// <returns>A task representing the deletion of the user.</returns>
  80. Task DeleteUserAsync(Guid userId);
  81. /// <summary>
  82. /// Resets the password.
  83. /// </summary>
  84. /// <param name="user">The user.</param>
  85. /// <returns>Task.</returns>
  86. Task ResetPassword(User user);
  87. /// <summary>
  88. /// Resets the easy password.
  89. /// </summary>
  90. /// <param name="user">The user.</param>
  91. /// <returns>Task.</returns>
  92. Task ResetEasyPassword(User user);
  93. /// <summary>
  94. /// Changes the password.
  95. /// </summary>
  96. /// <param name="user">The user.</param>
  97. /// <param name="newPassword">New password to use.</param>
  98. /// <returns>Awaitable task.</returns>
  99. Task ChangePassword(User user, string newPassword);
  100. /// <summary>
  101. /// Changes the easy password.
  102. /// </summary>
  103. /// <param name="user">The user.</param>
  104. /// <param name="newPassword">New password to use.</param>
  105. /// <param name="newPasswordSha1">Hash of new password.</param>
  106. /// <returns>Task.</returns>
  107. Task ChangeEasyPassword(User user, string newPassword, string newPasswordSha1);
  108. /// <summary>
  109. /// Gets the user dto.
  110. /// </summary>
  111. /// <param name="user">The user.</param>
  112. /// <param name="remoteEndPoint">The remote end point.</param>
  113. /// <returns>UserDto.</returns>
  114. UserDto GetUserDto(User user, string remoteEndPoint = null);
  115. /// <summary>
  116. /// Authenticates the user.
  117. /// </summary>
  118. /// <param name="username">The user.</param>
  119. /// <param name="password">The password to use.</param>
  120. /// <param name="passwordSha1">Hash of password.</param>
  121. /// <param name="remoteEndPoint">Remove endpoint to use.</param>
  122. /// <param name="isUserSession">Specifies if a user session.</param>
  123. /// <returns>User wrapped in awaitable task.</returns>
  124. Task<User> AuthenticateUser(string username, string password, string passwordSha1, string remoteEndPoint, bool isUserSession);
  125. /// <summary>
  126. /// Starts the forgot password process.
  127. /// </summary>
  128. /// <param name="enteredUsername">The entered username.</param>
  129. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  130. /// <returns>ForgotPasswordResult.</returns>
  131. Task<ForgotPasswordResult> StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  132. /// <summary>
  133. /// Redeems the password reset pin.
  134. /// </summary>
  135. /// <param name="pin">The pin.</param>
  136. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  137. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  138. NameIdPair[] GetAuthenticationProviders();
  139. NameIdPair[] GetPasswordResetProviders();
  140. /// <summary>
  141. /// This method updates the user's configuration.
  142. /// This is only included as a stopgap until the new API, using this internally is not recommended.
  143. /// Instead, modify the user object directly, then call <see cref="UpdateUserAsync"/>.
  144. /// </summary>
  145. /// <param name="userId">The user's Id.</param>
  146. /// <param name="config">The request containing the new user configuration.</param>
  147. /// <returns>A task representing the update.</returns>
  148. Task UpdateConfigurationAsync(Guid userId, UserConfiguration config);
  149. /// <summary>
  150. /// This method updates the user's policy.
  151. /// This is only included as a stopgap until the new API, using this internally is not recommended.
  152. /// Instead, modify the user object directly, then call <see cref="UpdateUserAsync"/>.
  153. /// </summary>
  154. /// <param name="userId">The user's Id.</param>
  155. /// <param name="policy">The request containing the new user policy.</param>
  156. /// <returns>A task representing the update.</returns>
  157. Task UpdatePolicyAsync(Guid userId, UserPolicy policy);
  158. /// <summary>
  159. /// Clears the user's profile image.
  160. /// </summary>
  161. /// <param name="user">The user.</param>
  162. /// <returns>A task representing the clearing of the profile image.</returns>
  163. Task ClearProfileImageAsync(User user);
  164. }
  165. }