IUserManager.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using Jellyfin.Data.Entities;
  5. using Jellyfin.Data.Events;
  6. using MediaBrowser.Model.Configuration;
  7. using MediaBrowser.Model.Dto;
  8. using MediaBrowser.Model.Users;
  9. namespace MediaBrowser.Controller.Library
  10. {
  11. /// <summary>
  12. /// Interface IUserManager.
  13. /// </summary>
  14. public interface IUserManager
  15. {
  16. /// <summary>
  17. /// Occurs when a user is updated.
  18. /// </summary>
  19. event EventHandler<GenericEventArgs<User>> OnUserUpdated;
  20. /// <summary>
  21. /// Gets the users.
  22. /// </summary>
  23. /// <value>The users.</value>
  24. IEnumerable<User> Users { get; }
  25. /// <summary>
  26. /// Gets the user ids.
  27. /// </summary>
  28. /// <value>The users ids.</value>
  29. IEnumerable<Guid> UsersIds { get; }
  30. /// <summary>
  31. /// Initializes the user manager and ensures that a user exists.
  32. /// </summary>
  33. Task InitializeAsync();
  34. /// <summary>
  35. /// Gets a user by Id.
  36. /// </summary>
  37. /// <param name="id">The id.</param>
  38. /// <returns>The user with the specified Id, or <c>null</c> if the user doesn't exist.</returns>
  39. /// <exception cref="ArgumentException"><c>id</c> is an empty Guid.</exception>
  40. User GetUserById(Guid id);
  41. /// <summary>
  42. /// Gets the name of the user by.
  43. /// </summary>
  44. /// <param name="name">The name.</param>
  45. /// <returns>User.</returns>
  46. User GetUserByName(string name);
  47. /// <summary>
  48. /// Renames the user.
  49. /// </summary>
  50. /// <param name="user">The user.</param>
  51. /// <param name="newName">The new name.</param>
  52. /// <returns>Task.</returns>
  53. /// <exception cref="ArgumentNullException">user</exception>
  54. /// <exception cref="ArgumentException"></exception>
  55. Task RenameUser(User user, string newName);
  56. /// <summary>
  57. /// Updates the user.
  58. /// </summary>
  59. /// <param name="user">The user.</param>
  60. /// <exception cref="ArgumentNullException">user</exception>
  61. /// <exception cref="ArgumentException"></exception>
  62. void UpdateUser(User user);
  63. /// <summary>
  64. /// Updates the user.
  65. /// </summary>
  66. /// <param name="user">The user.</param>
  67. /// <exception cref="ArgumentNullException">If user is <c>null</c>.</exception>
  68. /// <exception cref="ArgumentException">If the provided user doesn't exist.</exception>
  69. /// <returns>A task representing the update of the user.</returns>
  70. Task UpdateUserAsync(User user);
  71. /// <summary>
  72. /// Creates a user with the specified name.
  73. /// </summary>
  74. /// <param name="name">The name of the new user.</param>
  75. /// <returns>The created user.</returns>
  76. /// <exception cref="ArgumentNullException">name</exception>
  77. /// <exception cref="ArgumentException"></exception>
  78. Task<User> CreateUserAsync(string name);
  79. /// <summary>
  80. /// Deletes the specified user.
  81. /// </summary>
  82. /// <param name="userId">The id of the user to be deleted.</param>
  83. void DeleteUser(Guid userId);
  84. /// <summary>
  85. /// Resets the password.
  86. /// </summary>
  87. /// <param name="user">The user.</param>
  88. /// <returns>Task.</returns>
  89. Task ResetPassword(User user);
  90. /// <summary>
  91. /// Resets the easy password.
  92. /// </summary>
  93. /// <param name="user">The user.</param>
  94. /// <returns>Task.</returns>
  95. void ResetEasyPassword(User user);
  96. /// <summary>
  97. /// Changes the password.
  98. /// </summary>
  99. Task ChangePassword(User user, string newPassword);
  100. /// <summary>
  101. /// Changes the easy password.
  102. /// </summary>
  103. void ChangeEasyPassword(User user, string newPassword, string newPasswordSha1);
  104. /// <summary>
  105. /// Gets the user dto.
  106. /// </summary>
  107. /// <param name="user">The user.</param>
  108. /// <param name="remoteEndPoint">The remote end point.</param>
  109. /// <returns>UserDto.</returns>
  110. UserDto GetUserDto(User user, string remoteEndPoint = null);
  111. /// <summary>
  112. /// Authenticates the user.
  113. /// </summary>
  114. Task<User> AuthenticateUser(string username, string password, string passwordSha1, string remoteEndPoint, bool isUserSession);
  115. /// <summary>
  116. /// Starts the forgot password process.
  117. /// </summary>
  118. /// <param name="enteredUsername">The entered username.</param>
  119. /// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
  120. /// <returns>ForgotPasswordResult.</returns>
  121. Task<ForgotPasswordResult> StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
  122. /// <summary>
  123. /// Redeems the password reset pin.
  124. /// </summary>
  125. /// <param name="pin">The pin.</param>
  126. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  127. Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
  128. NameIdPair[] GetAuthenticationProviders();
  129. NameIdPair[] GetPasswordResetProviders();
  130. /// <summary>
  131. /// This method updates the user's configuration.
  132. /// This is only included as a stopgap until the new API, using this internally is not recommended.
  133. /// Instead, modify the user object directly, then call <see cref="UpdateUser"/>.
  134. /// </summary>
  135. /// <param name="userId">The user's Id.</param>
  136. /// <param name="config">The request containing the new user configuration.</param>
  137. void UpdateConfiguration(Guid userId, UserConfiguration config);
  138. /// <summary>
  139. /// This method updates the user's policy.
  140. /// This is only included as a stopgap until the new API, using this internally is not recommended.
  141. /// Instead, modify the user object directly, then call <see cref="UpdateUser"/>.
  142. /// </summary>
  143. /// <param name="userId">The user's Id.</param>
  144. /// <param name="policy">The request containing the new user policy.</param>
  145. void UpdatePolicy(Guid userId, UserPolicy policy);
  146. /// <summary>
  147. /// Clears the user's profile image.
  148. /// </summary>
  149. /// <param name="user">The user.</param>
  150. void ClearProfileImage(User user);
  151. }
  152. }