2
0

IUserManager.cs 6.6 KB

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