IUserManager.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Controller.Authentication;
  6. using MediaBrowser.Controller.Entities;
  7. using MediaBrowser.Model.Configuration;
  8. using MediaBrowser.Model.Dto;
  9. using MediaBrowser.Model.Events;
  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. /// Gets the users.
  20. /// </summary>
  21. /// <value>The users.</value>
  22. IEnumerable<User> Users { get; }
  23. /// <summary>
  24. /// Gets the user ids.
  25. /// </summary>
  26. /// <value>The users ids.</value>
  27. IEnumerable<Guid> UsersIds { get; }
  28. /// <summary>
  29. /// Occurs when [user updated].
  30. /// </summary>
  31. event EventHandler<GenericEventArgs<User>> UserUpdated;
  32. /// <summary>
  33. /// Occurs when [user deleted].
  34. /// </summary>
  35. event EventHandler<GenericEventArgs<User>> UserDeleted;
  36. event EventHandler<GenericEventArgs<User>> UserCreated;
  37. event EventHandler<GenericEventArgs<User>> UserPolicyUpdated;
  38. event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
  39. event EventHandler<GenericEventArgs<User>> UserPasswordChanged;
  40. event EventHandler<GenericEventArgs<User>> UserLockedOut;
  41. /// <summary>
  42. /// Gets a user by Id.
  43. /// </summary>
  44. /// <param name="id">The id.</param>
  45. /// <returns>The user with the specified Id, or <c>null</c> if the user doesn't exist.</returns>
  46. /// <exception cref="ArgumentException"><c>id</c> is an empty Guid.</exception>
  47. User GetUserById(Guid id);
  48. /// <summary>
  49. /// Gets the name of the user by.
  50. /// </summary>
  51. /// <param name="name">The name.</param>
  52. /// <returns>User.</returns>
  53. User GetUserByName(string name);
  54. /// <summary>
  55. /// Refreshes metadata for each user
  56. /// </summary>
  57. /// <param name="cancellationToken">The cancellation token.</param>
  58. /// <returns>Task.</returns>
  59. Task RefreshUsersMetadata(CancellationToken cancellationToken);
  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. /// Creates the user.
  78. /// </summary>
  79. /// <param name="name">The name.</param>
  80. /// <returns>User.</returns>
  81. /// <exception cref="ArgumentNullException">name</exception>
  82. /// <exception cref="ArgumentException"></exception>
  83. User CreateUser(string name);
  84. /// <summary>
  85. /// Deletes the user.
  86. /// </summary>
  87. /// <param name="user">The user.</param>
  88. /// <returns>Task.</returns>
  89. void DeleteUser(User user);
  90. /// <summary>
  91. /// Resets the password.
  92. /// </summary>
  93. /// <param name="user">The user.</param>
  94. /// <returns>Task.</returns>
  95. Task ResetPassword(User user);
  96. /// <summary>
  97. /// Gets the offline user dto.
  98. /// </summary>
  99. /// <param name="user">The user.</param>
  100. /// <returns>UserDto.</returns>
  101. UserDto GetOfflineUserDto(User user);
  102. /// <summary>
  103. /// Resets the easy password.
  104. /// </summary>
  105. /// <param name="user">The user.</param>
  106. /// <returns>Task.</returns>
  107. void ResetEasyPassword(User user);
  108. /// <summary>
  109. /// Changes the password.
  110. /// </summary>
  111. Task ChangePassword(User user, string newPassword);
  112. /// <summary>
  113. /// Changes the easy password.
  114. /// </summary>
  115. void ChangeEasyPassword(User user, string newPassword, string newPasswordSha1);
  116. /// <summary>
  117. /// Gets the user dto.
  118. /// </summary>
  119. /// <param name="user">The user.</param>
  120. /// <param name="remoteEndPoint">The remote end point.</param>
  121. /// <returns>UserDto.</returns>
  122. UserDto GetUserDto(User user, string remoteEndPoint = null);
  123. /// <summary>
  124. /// Gets the user public dto.
  125. /// </summary>
  126. /// <param name="user">Ther user.</param>\
  127. /// <param name="remoteEndPoint">The remote end point.</param>
  128. /// <returns>A public UserDto, aka a UserDto stripped of personal data.</returns>
  129. PublicUserDto GetPublicUserDto(User user, string remoteEndPoint = null);
  130. /// <summary>
  131. /// Authenticates the user.
  132. /// </summary>
  133. Task<User> AuthenticateUser(string username, string password, string passwordSha1, string remoteEndPoint, bool isUserSession);
  134. /// <summary>
  135. /// Starts the forgot password process.
  136. /// </summary>
  137. /// <param name="enteredUsername">The entered username.</param>
  138. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  139. /// <returns>ForgotPasswordResult.</returns>
  140. Task<ForgotPasswordResult> StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  141. /// <summary>
  142. /// Redeems the password reset pin.
  143. /// </summary>
  144. /// <param name="pin">The pin.</param>
  145. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  146. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  147. /// <summary>
  148. /// Gets the user policy.
  149. /// </summary>
  150. /// <param name="user">The user.</param>
  151. /// <returns>UserPolicy.</returns>
  152. UserPolicy GetUserPolicy(User user);
  153. /// <summary>
  154. /// Gets the user configuration.
  155. /// </summary>
  156. /// <param name="user">The user.</param>
  157. /// <returns>UserConfiguration.</returns>
  158. UserConfiguration GetUserConfiguration(User user);
  159. /// <summary>
  160. /// Updates the configuration.
  161. /// </summary>
  162. /// <param name="userId">The user identifier.</param>
  163. /// <param name="newConfiguration">The new configuration.</param>
  164. /// <returns>Task.</returns>
  165. void UpdateConfiguration(Guid userId, UserConfiguration newConfiguration);
  166. void UpdateConfiguration(User user, UserConfiguration newConfiguration);
  167. /// <summary>
  168. /// Updates the user policy.
  169. /// </summary>
  170. /// <param name="userId">The user identifier.</param>
  171. /// <param name="userPolicy">The user policy.</param>
  172. void UpdateUserPolicy(Guid userId, UserPolicy userPolicy);
  173. /// <summary>
  174. /// Makes the valid username.
  175. /// </summary>
  176. /// <param name="username">The username.</param>
  177. /// <returns>System.String.</returns>
  178. string MakeValidUsername(string username);
  179. void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders, IEnumerable<IPasswordResetProvider> passwordResetProviders);
  180. NameIdPair[] GetAuthenticationProviders();
  181. NameIdPair[] GetPasswordResetProviders();
  182. }
  183. }