aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Library/IUserManager.cs
blob: 4ff3cee0f0b0cd9c4d2dcb7c468f045a8756e02a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Users;

namespace MediaBrowser.Controller.Library
{
    /// <summary>
    /// Interface IUserManager.
    /// </summary>
    public interface IUserManager
    {
        /// <summary>
        /// Occurs when a user is updated.
        /// </summary>
        event EventHandler<GenericEventArgs<User>> OnUserUpdated;

        /// <summary>
        /// Occurs when a user is created.
        /// </summary>
        event EventHandler<GenericEventArgs<User>> OnUserCreated;

        /// <summary>
        /// Occurs when a user is deleted.
        /// </summary>
        event EventHandler<GenericEventArgs<User>> OnUserDeleted;

        /// <summary>
        /// Occurs when a user's password is changed.
        /// </summary>
        event EventHandler<GenericEventArgs<User>> OnUserPasswordChanged;

        /// <summary>
        /// Occurs when a user is locked out.
        /// </summary>
        event EventHandler<GenericEventArgs<User>> OnUserLockedOut;

        /// <summary>
        /// Gets the users.
        /// </summary>
        /// <value>The users.</value>
        IEnumerable<User> Users { get; }

        /// <summary>
        /// Gets the user ids.
        /// </summary>
        /// <value>The users ids.</value>
        IEnumerable<Guid> UsersIds { get; }

        /// <summary>
        /// Initializes the user manager and ensures that a user exists.
        /// </summary>
        void Initialize();

        /// <summary>
        /// Gets a user by Id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns>The user with the specified Id, or <c>null</c> if the user doesn't exist.</returns>
        /// <exception cref="ArgumentException"><c>id</c> is an empty Guid.</exception>
        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>
        /// <exception cref="ArgumentNullException">user</exception>
        /// <exception cref="ArgumentException"></exception>
        Task RenameUser(User user, string newName);

        /// <summary>
        /// Updates the user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <exception cref="ArgumentNullException">user</exception>
        /// <exception cref="ArgumentException"></exception>
        void UpdateUser(User user);

        /// <summary>
        /// Updates the user.
        /// </summary>
        /// <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>
        /// <exception cref="ArgumentNullException">name</exception>
        /// <exception cref="ArgumentException"></exception>
        User CreateUser(string name);

        /// <summary>
        /// Deletes the specified user.
        /// </summary>
        /// <param name="userId">The if of the user to be deleted.</param>
        void DeleteUser(Guid userId);

        /// <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);

        /// <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);

        /// <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);

        void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders, IEnumerable<IPasswordResetProvider> passwordResetProviders);

        NameIdPair[] GetAuthenticationProviders();

        NameIdPair[] GetPasswordResetProviders();

        /// <summary>
        /// This method updates the user's configuration.
        /// This is only included as a stopgap until the new API, using this internally is not recommended.
        /// Instead, modify the user object directly, then call <see cref="UpdateUser"/>.
        /// </summary>
        /// <param name="userId">The user's Id.</param>
        /// <param name="config">The request containing the new user configuration.</param>
        void UpdateConfiguration(Guid userId, UserConfiguration config);

        /// <summary>
        /// This method updates the user's policy.
        /// This is only included as a stopgap until the new API, using this internally is not recommended.
        /// Instead, modify the user object directly, then call <see cref="UpdateUser"/>.
        /// </summary>
        /// <param name="userId">The user's Id.</param>
        /// <param name="policy">The request containing the new user policy.</param>
        void UpdatePolicy(Guid userId, UserPolicy policy);

        /// <summary>
        /// Clears the user's profile image.
        /// </summary>
        /// <param name="user">The user.</param>
        void ClearProfileImage(User user);
    }
}