IUserManager.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. /// Authenticates the user.
  125. /// </summary>
  126. Task<User> AuthenticateUser(string username, string password, string passwordSha1, string remoteEndPoint, bool isUserSession);
  127. /// <summary>
  128. /// Starts the forgot password process.
  129. /// </summary>
  130. /// <param name="enteredUsername">The entered username.</param>
  131. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  132. /// <returns>ForgotPasswordResult.</returns>
  133. Task<ForgotPasswordResult> StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  134. /// <summary>
  135. /// Redeems the password reset pin.
  136. /// </summary>
  137. /// <param name="pin">The pin.</param>
  138. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  139. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  140. /// <summary>
  141. /// Gets the user policy.
  142. /// </summary>
  143. /// <param name="user">The user.</param>
  144. /// <returns>UserPolicy.</returns>
  145. UserPolicy GetUserPolicy(User user);
  146. /// <summary>
  147. /// Gets the user configuration.
  148. /// </summary>
  149. /// <param name="user">The user.</param>
  150. /// <returns>UserConfiguration.</returns>
  151. UserConfiguration GetUserConfiguration(User user);
  152. /// <summary>
  153. /// Updates the configuration.
  154. /// </summary>
  155. /// <param name="userId">The user identifier.</param>
  156. /// <param name="newConfiguration">The new configuration.</param>
  157. /// <returns>Task.</returns>
  158. void UpdateConfiguration(Guid userId, UserConfiguration newConfiguration);
  159. void UpdateConfiguration(User user, UserConfiguration newConfiguration);
  160. /// <summary>
  161. /// Updates the user policy.
  162. /// </summary>
  163. /// <param name="userId">The user identifier.</param>
  164. /// <param name="userPolicy">The user policy.</param>
  165. void UpdateUserPolicy(Guid userId, UserPolicy userPolicy);
  166. /// <summary>
  167. /// Makes the valid username.
  168. /// </summary>
  169. /// <param name="username">The username.</param>
  170. /// <returns>System.String.</returns>
  171. string MakeValidUsername(string username);
  172. void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders, IEnumerable<IPasswordResetProvider> passwordResetProviders);
  173. NameIdPair[] GetAuthenticationProviders();
  174. NameIdPair[] GetPasswordResetProviders();
  175. }
  176. }