IUserManager.cs 6.7 KB

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