IUserManager.cs 7.2 KB

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