IUserManager.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. /// Occurs when [user updated].
  25. /// </summary>
  26. event EventHandler<GenericEventArgs<User>> UserUpdated;
  27. /// <summary>
  28. /// Occurs when [user deleted].
  29. /// </summary>
  30. event EventHandler<GenericEventArgs<User>> UserDeleted;
  31. event EventHandler<GenericEventArgs<User>> UserCreated;
  32. event EventHandler<GenericEventArgs<User>> UserPolicyUpdated;
  33. event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
  34. event EventHandler<GenericEventArgs<User>> UserPasswordChanged;
  35. event EventHandler<GenericEventArgs<User>> UserLockedOut;
  36. /// <summary>
  37. /// Gets a User by Id
  38. /// </summary>
  39. /// <param name="id">The id.</param>
  40. /// <returns>User.</returns>
  41. /// <exception cref="ArgumentNullException"></exception>
  42. User GetUserById(Guid id);
  43. /// <summary>
  44. /// Gets the user by identifier.
  45. /// </summary>
  46. /// <param name="id">The identifier.</param>
  47. /// <returns>User.</returns>
  48. User GetUserById(string id);
  49. /// <summary>
  50. /// Gets the name of the user by.
  51. /// </summary>
  52. /// <param name="name">The name.</param>
  53. /// <returns>User.</returns>
  54. User GetUserByName(string name);
  55. /// <summary>
  56. /// Refreshes metadata for each user
  57. /// </summary>
  58. /// <param name="cancellationToken">The cancellation token.</param>
  59. /// <returns>Task.</returns>
  60. Task RefreshUsersMetadata(CancellationToken cancellationToken);
  61. /// <summary>
  62. /// Renames the user.
  63. /// </summary>
  64. /// <param name="user">The user.</param>
  65. /// <param name="newName">The new name.</param>
  66. /// <returns>Task.</returns>
  67. /// <exception cref="ArgumentNullException">user</exception>
  68. /// <exception cref="ArgumentException"></exception>
  69. Task RenameUser(User user, string newName);
  70. /// <summary>
  71. /// Updates the user.
  72. /// </summary>
  73. /// <param name="user">The user.</param>
  74. /// <exception cref="ArgumentNullException">user</exception>
  75. /// <exception cref="ArgumentException"></exception>
  76. void UpdateUser(User user);
  77. /// <summary>
  78. /// Creates the user.
  79. /// </summary>
  80. /// <param name="name">The name.</param>
  81. /// <returns>User.</returns>
  82. /// <exception cref="ArgumentNullException">name</exception>
  83. /// <exception cref="ArgumentException"></exception>
  84. Task<User> CreateUser(string name);
  85. /// <summary>
  86. /// Deletes the user.
  87. /// </summary>
  88. /// <param name="user">The user.</param>
  89. /// <returns>Task.</returns>
  90. /// <exception cref="ArgumentNullException">user</exception>
  91. /// <exception cref="ArgumentException"></exception>
  92. Task DeleteUser(User user);
  93. /// <summary>
  94. /// Resets the password.
  95. /// </summary>
  96. /// <param name="user">The user.</param>
  97. /// <returns>Task.</returns>
  98. Task ResetPassword(User user);
  99. /// <summary>
  100. /// Gets the offline user dto.
  101. /// </summary>
  102. /// <param name="user">The user.</param>
  103. /// <returns>UserDto.</returns>
  104. UserDto GetOfflineUserDto(User user);
  105. /// <summary>
  106. /// Resets the easy password.
  107. /// </summary>
  108. /// <param name="user">The user.</param>
  109. /// <returns>Task.</returns>
  110. void ResetEasyPassword(User user);
  111. /// <summary>
  112. /// Changes the password.
  113. /// </summary>
  114. Task ChangePassword(User user, string newPassword);
  115. /// <summary>
  116. /// Changes the easy password.
  117. /// </summary>
  118. void ChangeEasyPassword(User user, string newPassword, string newPasswordSha1);
  119. /// <summary>
  120. /// Gets the user dto.
  121. /// </summary>
  122. /// <param name="user">The user.</param>
  123. /// <param name="remoteEndPoint">The remote end point.</param>
  124. /// <returns>UserDto.</returns>
  125. UserDto GetUserDto(User user, string remoteEndPoint = null);
  126. /// <summary>
  127. /// Authenticates the user.
  128. /// </summary>
  129. Task<User> AuthenticateUser(string username, string password, string passwordSha1, string remoteEndPoint, bool isUserSession);
  130. /// <summary>
  131. /// Starts the forgot password process.
  132. /// </summary>
  133. /// <param name="enteredUsername">The entered username.</param>
  134. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  135. /// <returns>ForgotPasswordResult.</returns>
  136. Task<ForgotPasswordResult> StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  137. /// <summary>
  138. /// Redeems the password reset pin.
  139. /// </summary>
  140. /// <param name="pin">The pin.</param>
  141. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  142. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  143. /// <summary>
  144. /// Gets the user policy.
  145. /// </summary>
  146. /// <param name="user">The user.</param>
  147. /// <returns>UserPolicy.</returns>
  148. UserPolicy GetUserPolicy(User user);
  149. /// <summary>
  150. /// Gets the user configuration.
  151. /// </summary>
  152. /// <param name="user">The user.</param>
  153. /// <returns>UserConfiguration.</returns>
  154. UserConfiguration GetUserConfiguration(User user);
  155. /// <summary>
  156. /// Updates the configuration.
  157. /// </summary>
  158. /// <param name="userId">The user identifier.</param>
  159. /// <param name="newConfiguration">The new configuration.</param>
  160. /// <returns>Task.</returns>
  161. void UpdateConfiguration(Guid userId, UserConfiguration newConfiguration);
  162. void UpdateConfiguration(User user, UserConfiguration newConfiguration);
  163. /// <summary>
  164. /// Updates the user policy.
  165. /// </summary>
  166. /// <param name="userId">The user identifier.</param>
  167. /// <param name="userPolicy">The user policy.</param>
  168. void UpdateUserPolicy(Guid userId, UserPolicy userPolicy);
  169. /// <summary>
  170. /// Makes the valid username.
  171. /// </summary>
  172. /// <param name="username">The username.</param>
  173. /// <returns>System.String.</returns>
  174. string MakeValidUsername(string username);
  175. void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders, IEnumerable<IPasswordResetProvider> passwordResetProviders);
  176. NameIdPair[] GetAuthenticationProviders();
  177. NameIdPair[] GetPasswordResetProviders();
  178. }
  179. }