2021-05-06 22:39:20 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 19:56:24 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 20:01:16 +00:00
|
|
|
using System;
|
2018-12-27 23:27:57 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
2020-05-13 02:10:35 +00:00
|
|
|
using Jellyfin.Data.Entities;
|
2020-08-14 00:48:28 +00:00
|
|
|
using Jellyfin.Data.Events;
|
2019-01-13 19:25:32 +00:00
|
|
|
using MediaBrowser.Model.Configuration;
|
|
|
|
using MediaBrowser.Model.Dto;
|
|
|
|
using MediaBrowser.Model.Users;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Library
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Interface IUserManager.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
public interface IUserManager
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
/// Occurs when a user is updated.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
event EventHandler<GenericEventArgs<User>> OnUserUpdated;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2020-05-13 02:10:35 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the users.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The users.</value>
|
|
|
|
IEnumerable<User> Users { get; }
|
2019-10-20 19:12:03 +00:00
|
|
|
|
2020-05-13 02:10:35 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the user ids.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The users ids.</value>
|
|
|
|
IEnumerable<Guid> UsersIds { get; }
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2020-06-09 18:01:21 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes the user manager and ensures that a user exists.
|
|
|
|
/// </summary>
|
2020-07-22 18:57:29 +00:00
|
|
|
Task InitializeAsync();
|
2020-06-09 18:01:21 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
2019-11-17 22:05:39 +00:00
|
|
|
/// Gets a user by Id.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">The id.</param>
|
2019-10-29 16:50:09 +00:00
|
|
|
/// <returns>The user with the specified Id, or <c>null</c> if the user doesn't exist.</returns>
|
2019-10-20 19:12:03 +00:00
|
|
|
/// <exception cref="ArgumentException"><c>id</c> is an empty Guid.</exception>
|
2018-12-27 23:27:57 +00:00
|
|
|
User GetUserById(Guid id);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the name of the user by.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
/// <returns>User.</returns>
|
|
|
|
User GetUserByName(string name);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Renames the user.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
/// <param name="newName">The new name.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2019-01-13 20:37:13 +00:00
|
|
|
/// <exception cref="ArgumentNullException">user</exception>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
2018-12-27 23:27:57 +00:00
|
|
|
Task RenameUser(User user, string newName);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Updates the user.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
2019-01-13 20:37:13 +00:00
|
|
|
/// <exception cref="ArgumentNullException">user</exception>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
2018-12-27 23:27:57 +00:00
|
|
|
void UpdateUser(User user);
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
/// Updates the user.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
/// <exception cref="ArgumentNullException">If user is <c>null</c>.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If the provided user doesn't exist.</exception>
|
|
|
|
/// <returns>A task representing the update of the user.</returns>
|
|
|
|
Task UpdateUserAsync(User user);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a user with the specified name.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="name">The name of the new user.</param>
|
|
|
|
/// <returns>The created user.</returns>
|
2019-01-13 20:37:13 +00:00
|
|
|
/// <exception cref="ArgumentNullException">name</exception>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
2020-07-22 18:57:29 +00:00
|
|
|
Task<User> CreateUserAsync(string name);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
/// Deletes the specified user.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
2020-06-25 01:07:39 +00:00
|
|
|
/// <param name="userId">The id of the user to be deleted.</param>
|
2020-12-11 15:15:43 +00:00
|
|
|
/// <returns>A task representing the deletion of the user.</returns>
|
|
|
|
Task DeleteUserAsync(Guid userId);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Resets the password.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task ResetPassword(User user);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Resets the easy password.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
void ResetEasyPassword(User user);
|
2019-01-07 23:27:46 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Changes the password.
|
|
|
|
/// </summary>
|
|
|
|
Task ChangePassword(User user, string newPassword);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Changes the easy password.
|
|
|
|
/// </summary>
|
|
|
|
void ChangeEasyPassword(User user, string newPassword, string newPasswordSha1);
|
2019-01-07 23:27:46 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the user dto.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
/// <param name="remoteEndPoint">The remote end point.</param>
|
|
|
|
/// <returns>UserDto.</returns>
|
|
|
|
UserDto GetUserDto(User user, string remoteEndPoint = null);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Authenticates the user.
|
|
|
|
/// </summary>
|
|
|
|
Task<User> AuthenticateUser(string username, string password, string passwordSha1, string remoteEndPoint, bool isUserSession);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Starts the forgot password process.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="enteredUsername">The entered username.</param>
|
|
|
|
/// <param name="isInNetwork">if set to <c>true</c> [is in network].</param>
|
|
|
|
/// <returns>ForgotPasswordResult.</returns>
|
|
|
|
Task<ForgotPasswordResult> StartForgotPasswordProcess(string enteredUsername, bool isInNetwork);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Redeems the password reset pin.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pin">The pin.</param>
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
|
|
|
|
|
2020-05-13 02:10:35 +00:00
|
|
|
NameIdPair[] GetAuthenticationProviders();
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2020-05-13 02:10:35 +00:00
|
|
|
NameIdPair[] GetPasswordResetProviders();
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
/// This method updates the user's configuration.
|
|
|
|
/// This is only included as a stopgap until the new API, using this internally is not recommended.
|
2020-06-11 21:51:02 +00:00
|
|
|
/// Instead, modify the user object directly, then call <see cref="UpdateUser"/>.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
/// <param name="userId">The user's Id.</param>
|
|
|
|
/// <param name="config">The request containing the new user configuration.</param>
|
2020-10-30 00:30:33 +00:00
|
|
|
/// <returns>A task representing the update.</returns>
|
|
|
|
Task UpdateConfigurationAsync(Guid userId, UserConfiguration config);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
/// This method updates the user's policy.
|
|
|
|
/// This is only included as a stopgap until the new API, using this internally is not recommended.
|
2020-06-11 21:51:02 +00:00
|
|
|
/// Instead, modify the user object directly, then call <see cref="UpdateUser"/>.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
2020-05-13 02:10:35 +00:00
|
|
|
/// <param name="userId">The user's Id.</param>
|
|
|
|
/// <param name="policy">The request containing the new user policy.</param>
|
2020-10-30 00:30:33 +00:00
|
|
|
/// <returns>A task representing the update.</returns>
|
|
|
|
Task UpdatePolicyAsync(Guid userId, UserPolicy policy);
|
2020-06-11 21:51:02 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Clears the user's profile image.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
2020-10-30 00:30:33 +00:00
|
|
|
/// <returns>A task representing the clearing of the profile image.</returns>
|
|
|
|
Task ClearProfileImageAsync(User user);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|