IUserManager.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. /// Gets a user by Id.
  49. /// </summary>
  50. /// <param name="id">The id.</param>
  51. /// <returns>The user with the specified Id, or <c>null</c> if the user doesn't exist.</returns>
  52. /// <exception cref="ArgumentException"><c>id</c> is an empty Guid.</exception>
  53. User GetUserById(Guid id);
  54. /// <summary>
  55. /// Gets the name of the user by.
  56. /// </summary>
  57. /// <param name="name">The name.</param>
  58. /// <returns>User.</returns>
  59. User GetUserByName(string name);
  60. /// <summary>
  61. /// Renames the user.
  62. /// </summary>
  63. /// <param name="user">The user.</param>
  64. /// <param name="newName">The new name.</param>
  65. /// <returns>Task.</returns>
  66. /// <exception cref="ArgumentNullException">user</exception>
  67. /// <exception cref="ArgumentException"></exception>
  68. Task RenameUser(User user, string newName);
  69. /// <summary>
  70. /// Updates the user.
  71. /// </summary>
  72. /// <param name="user">The user.</param>
  73. /// <exception cref="ArgumentNullException">user</exception>
  74. /// <exception cref="ArgumentException"></exception>
  75. void UpdateUser(User user);
  76. /// <summary>
  77. /// Updates the user.
  78. /// </summary>
  79. /// <param name="user">The user.</param>
  80. /// <exception cref="ArgumentNullException">If user is <c>null</c>.</exception>
  81. /// <exception cref="ArgumentException">If the provided user doesn't exist.</exception>
  82. /// <returns>A task representing the update of the user.</returns>
  83. Task UpdateUserAsync(User user);
  84. /// <summary>
  85. /// Creates a user with the specified name.
  86. /// </summary>
  87. /// <param name="name">The name of the new user.</param>
  88. /// <returns>The created user.</returns>
  89. /// <exception cref="ArgumentNullException">name</exception>
  90. /// <exception cref="ArgumentException"></exception>
  91. User CreateUser(string name);
  92. /// <summary>
  93. /// Deletes the specified user.
  94. /// </summary>
  95. /// <param name="user">The user to be deleted.</param>
  96. void DeleteUser(User user);
  97. /// <summary>
  98. /// Resets the password.
  99. /// </summary>
  100. /// <param name="user">The user.</param>
  101. /// <returns>Task.</returns>
  102. Task ResetPassword(User user);
  103. /// <summary>
  104. /// Resets the easy password.
  105. /// </summary>
  106. /// <param name="user">The user.</param>
  107. /// <returns>Task.</returns>
  108. void ResetEasyPassword(User user);
  109. /// <summary>
  110. /// Changes the password.
  111. /// </summary>
  112. Task ChangePassword(User user, string newPassword);
  113. /// <summary>
  114. /// Changes the easy password.
  115. /// </summary>
  116. void ChangeEasyPassword(User user, string newPassword, string newPasswordSha1);
  117. /// <summary>
  118. /// Gets the user dto.
  119. /// </summary>
  120. /// <param name="user">The user.</param>
  121. /// <param name="remoteEndPoint">The remote end point.</param>
  122. /// <returns>UserDto.</returns>
  123. UserDto GetUserDto(User user, string remoteEndPoint = null);
  124. /// <summary>
  125. /// Gets the user public dto.
  126. /// </summary>
  127. /// <param name="user">Ther user.</param>\
  128. /// <param name="remoteEndPoint">The remote end point.</param>
  129. /// <returns>A public UserDto, aka a UserDto stripped of personal data.</returns>
  130. PublicUserDto GetPublicUserDto(User user, string remoteEndPoint = null);
  131. /// <summary>
  132. /// Authenticates the user.
  133. /// </summary>
  134. Task<User> AuthenticateUser(string username, string password, string passwordSha1, string remoteEndPoint, bool isUserSession);
  135. /// <summary>
  136. /// Starts the forgot password process.
  137. /// </summary>
  138. /// <param name="enteredUsername">The entered username.</param>
  139. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  140. /// <returns>ForgotPasswordResult.</returns>
  141. Task<ForgotPasswordResult> StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  142. /// <summary>
  143. /// Redeems the password reset pin.
  144. /// </summary>
  145. /// <param name="pin">The pin.</param>
  146. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  147. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  148. void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders, IEnumerable<IPasswordResetProvider> passwordResetProviders);
  149. NameIdPair[] GetAuthenticationProviders();
  150. NameIdPair[] GetPasswordResetProviders();
  151. /// <summary>
  152. /// This method updates the user's configuration.
  153. /// This is only included as a stopgap until the new API, using this internally is not recommended.
  154. /// Instead, modify the user object directlu, then call <see cref="UpdateUser"/>.
  155. /// </summary>
  156. /// <param name="userId">The user's Id.</param>
  157. /// <param name="config">The request containing the new user configuration.</param>
  158. void UpdateConfiguration(Guid userId, UserConfiguration config);
  159. /// <summary>
  160. /// This method updates the user's policy.
  161. /// This is only included as a stopgap until the new API, using this internally is not recommended.
  162. /// Instead, modify the user object directlu, then call <see cref="UpdateUser"/>.
  163. /// </summary>
  164. /// <param name="userId">The user's Id.</param>
  165. /// <param name="policy">The request containing the new user policy.</param>
  166. void UpdatePolicy(Guid userId, UserPolicy policy);
  167. }
  168. }