IUserManager.cs 7.0 KB

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