IUserManager.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. /// Resets the easy password.
  107. /// </summary>
  108. /// <param name="user">The user.</param>
  109. /// <returns>Task.</returns>
  110. Task ResetEasyPassword(User user);
  111. /// <summary>
  112. /// Changes the password.
  113. /// </summary>
  114. /// <param name="user">The user.</param>
  115. /// <param name="newPasswordSha1">The new password sha1.</param>
  116. /// <returns>Task.</returns>
  117. Task ChangePassword(User user, string newPasswordSha1);
  118. /// <summary>
  119. /// Changes the easy password.
  120. /// </summary>
  121. /// <param name="user">The user.</param>
  122. /// <param name="newPasswordSha1">The new password sha1.</param>
  123. /// <returns>Task.</returns>
  124. Task ChangeEasyPassword(User user, string newPasswordSha1);
  125. /// <summary>
  126. /// Gets the user dto.
  127. /// </summary>
  128. /// <param name="user">The user.</param>
  129. /// <param name="remoteEndPoint">The remote end point.</param>
  130. /// <returns>UserDto.</returns>
  131. UserDto GetUserDto(User user, string remoteEndPoint = null);
  132. /// <summary>
  133. /// Authenticates the user.
  134. /// </summary>
  135. /// <param name="username">The username.</param>
  136. /// <param name="passwordSha1">The password sha1.</param>
  137. /// <param name="passwordMd5">The password MD5.</param>
  138. /// <param name="remoteEndPoint">The remote end point.</param>
  139. /// <returns>Task&lt;System.Boolean&gt;.</returns>
  140. Task<bool> AuthenticateUser(string username, string passwordSha1, string passwordMd5, string remoteEndPoint);
  141. /// <summary>
  142. /// Starts the forgot password process.
  143. /// </summary>
  144. /// <param name="enteredUsername">The entered username.</param>
  145. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  146. /// <returns>ForgotPasswordResult.</returns>
  147. ForgotPasswordResult StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  148. /// <summary>
  149. /// Redeems the password reset pin.
  150. /// </summary>
  151. /// <param name="pin">The pin.</param>
  152. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  153. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  154. /// <summary>
  155. /// Gets the user policy.
  156. /// </summary>
  157. /// <param name="user">The user.</param>
  158. /// <returns>UserPolicy.</returns>
  159. UserPolicy GetUserPolicy(User user);
  160. /// <summary>
  161. /// Gets the user configuration.
  162. /// </summary>
  163. /// <param name="user">The user.</param>
  164. /// <returns>UserConfiguration.</returns>
  165. UserConfiguration GetUserConfiguration(User user);
  166. /// <summary>
  167. /// Updates the configuration.
  168. /// </summary>
  169. /// <param name="userId">The user identifier.</param>
  170. /// <param name="newConfiguration">The new configuration.</param>
  171. /// <returns>Task.</returns>
  172. Task UpdateConfiguration(string userId, UserConfiguration newConfiguration);
  173. /// <summary>
  174. /// Updates the user policy.
  175. /// </summary>
  176. /// <param name="userId">The user identifier.</param>
  177. /// <param name="userPolicy">The user policy.</param>
  178. Task UpdateUserPolicy(string userId, UserPolicy userPolicy);
  179. /// <summary>
  180. /// Makes the valid username.
  181. /// </summary>
  182. /// <param name="username">The username.</param>
  183. /// <returns>System.String.</returns>
  184. string MakeValidUsername(string username);
  185. }
  186. }