IUserManager.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Model.Configuration;
  3. using MediaBrowser.Model.Dto;
  4. using MediaBrowser.Model.Events;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  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. /// Gets the users.
  19. /// </summary>
  20. /// <value>The users.</value>
  21. IEnumerable<User> Users { get; }
  22. /// <summary>
  23. /// Occurs when [user updated].
  24. /// </summary>
  25. event EventHandler<GenericEventArgs<User>> UserUpdated;
  26. /// <summary>
  27. /// Occurs when [user deleted].
  28. /// </summary>
  29. event EventHandler<GenericEventArgs<User>> UserDeleted;
  30. event EventHandler<GenericEventArgs<User>> UserCreated;
  31. event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
  32. event EventHandler<GenericEventArgs<User>> UserPasswordChanged;
  33. /// <summary>
  34. /// Gets a User by Id
  35. /// </summary>
  36. /// <param name="id">The id.</param>
  37. /// <returns>User.</returns>
  38. /// <exception cref="System.ArgumentNullException"></exception>
  39. User GetUserById(Guid id);
  40. /// <summary>
  41. /// Gets the user by identifier.
  42. /// </summary>
  43. /// <param name="id">The identifier.</param>
  44. /// <returns>User.</returns>
  45. User GetUserById(string id);
  46. /// <summary>
  47. /// Gets the name of the user by.
  48. /// </summary>
  49. /// <param name="name">The name.</param>
  50. /// <returns>User.</returns>
  51. User GetUserByName(string name);
  52. /// <summary>
  53. /// Authenticates a User and returns a result indicating whether or not it succeeded
  54. /// </summary>
  55. /// <param name="username">The username.</param>
  56. /// <param name="passwordSha1">The password sha1.</param>
  57. /// <param name="remoteEndPoint">The remote end point.</param>
  58. /// <returns>Task{System.Boolean}.</returns>
  59. /// <exception cref="System.ArgumentNullException">user</exception>
  60. Task<bool> AuthenticateUser(string username, string passwordSha1, string remoteEndPoint);
  61. /// <summary>
  62. /// Refreshes metadata for each user
  63. /// </summary>
  64. /// <param name="cancellationToken">The cancellation token.</param>
  65. /// <returns>Task.</returns>
  66. Task RefreshUsersMetadata(CancellationToken cancellationToken);
  67. /// <summary>
  68. /// Renames the user.
  69. /// </summary>
  70. /// <param name="user">The user.</param>
  71. /// <param name="newName">The new name.</param>
  72. /// <returns>Task.</returns>
  73. /// <exception cref="System.ArgumentNullException">user</exception>
  74. /// <exception cref="System.ArgumentException"></exception>
  75. Task RenameUser(User user, string newName);
  76. /// <summary>
  77. /// Updates the user.
  78. /// </summary>
  79. /// <param name="user">The user.</param>
  80. /// <exception cref="System.ArgumentNullException">user</exception>
  81. /// <exception cref="System.ArgumentException"></exception>
  82. Task UpdateUser(User user);
  83. /// <summary>
  84. /// Creates the user.
  85. /// </summary>
  86. /// <param name="name">The name.</param>
  87. /// <returns>User.</returns>
  88. /// <exception cref="System.ArgumentNullException">name</exception>
  89. /// <exception cref="System.ArgumentException"></exception>
  90. Task<User> CreateUser(string name);
  91. /// <summary>
  92. /// Deletes the user.
  93. /// </summary>
  94. /// <param name="user">The user.</param>
  95. /// <returns>Task.</returns>
  96. /// <exception cref="System.ArgumentNullException">user</exception>
  97. /// <exception cref="System.ArgumentException"></exception>
  98. Task DeleteUser(User user);
  99. /// <summary>
  100. /// Resets the password.
  101. /// </summary>
  102. /// <param name="user">The user.</param>
  103. /// <returns>Task.</returns>
  104. Task ResetPassword(User user);
  105. /// <summary>
  106. /// Changes the password.
  107. /// </summary>
  108. /// <param name="user">The user.</param>
  109. /// <param name="newPasswordSha1">The new password sha1.</param>
  110. /// <returns>Task.</returns>
  111. Task ChangePassword(User user, string newPasswordSha1);
  112. /// <summary>
  113. /// Gets the user dto.
  114. /// </summary>
  115. /// <param name="user">The user.</param>
  116. /// <param name="remoteEndPoint">The remote end point.</param>
  117. /// <returns>UserDto.</returns>
  118. UserDto GetUserDto(User user, string remoteEndPoint = null);
  119. /// <summary>
  120. /// Authenticates the user.
  121. /// </summary>
  122. /// <param name="username">The username.</param>
  123. /// <param name="passwordSha1">The password sha1.</param>
  124. /// <param name="passwordMd5">The password MD5.</param>
  125. /// <param name="remoteEndPoint">The remote end point.</param>
  126. /// <returns>Task&lt;System.Boolean&gt;.</returns>
  127. Task<bool> AuthenticateUser(string username, string passwordSha1, string passwordMd5, string remoteEndPoint);
  128. /// <summary>
  129. /// Starts the forgot password process.
  130. /// </summary>
  131. /// <param name="enteredUsername">The entered username.</param>
  132. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  133. /// <returns>ForgotPasswordResult.</returns>
  134. ForgotPasswordResult StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  135. /// <summary>
  136. /// Redeems the password reset pin.
  137. /// </summary>
  138. /// <param name="pin">The pin.</param>
  139. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  140. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  141. /// <summary>
  142. /// Gets the user policy.
  143. /// </summary>
  144. /// <param name="user">The user.</param>
  145. /// <returns>UserPolicy.</returns>
  146. UserPolicy GetUserPolicy(User user);
  147. /// <summary>
  148. /// Gets the user configuration.
  149. /// </summary>
  150. /// <param name="user">The user.</param>
  151. /// <returns>UserConfiguration.</returns>
  152. UserConfiguration GetUserConfiguration(User user);
  153. /// <summary>
  154. /// Updates the configuration.
  155. /// </summary>
  156. /// <param name="userId">The user identifier.</param>
  157. /// <param name="newConfiguration">The new configuration.</param>
  158. /// <returns>Task.</returns>
  159. Task UpdateConfiguration(string userId, 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. Task UpdateUserPolicy(string 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. }
  173. }