-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaces.cs
More file actions
36 lines (36 loc) · 1.37 KB
/
Interfaces.cs
File metadata and controls
36 lines (36 loc) · 1.37 KB
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
namespace Webtech3;
/// <summary>
/// Interface for class, that can be used for auth the users
/// </summary>
public interface IAuthManager {
/// <summary>
/// Users storage, with that AuthManager works
/// </summary>
/// <value>Accessible for reading anywhere & anytime, but for writing only once</value>
public IUsersRepository<User> Users { get; init; }
/// <summary>
/// Authorize the user by request data
/// </summary>
/// <param name="req">Request data</param>
/// <returns>User if success, null otherwise</returns>
public User? Authorize(Request req);
/// <summary>
/// Authentificate the user by request data.
/// Set Request's property "CurrentUser".
/// </summary>
/// <param name="req">Request data</param>
/// <returns>If success - User, otherwise - null</returns>
public User? Authentificate(Request req);
}
/// <summary>
/// Interface for class, that can be used as Users storage
/// </summary>
/// <typeparam name="UserType">Type extending std User record type</typeparam>
public interface IUsersRepository<UserType> : IEnumerable<UserType> where UserType : User {
public UserType? Get(ulong id);
public void Add(UserType u);
public void Remove(UserType u);
public void Remove(ulong id);
public void Replace(UserType old, UserType @new);
public void Replace(ulong id, UserType @new);
}