-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathIUserRepository.cs
More file actions
153 lines (132 loc) · 5.51 KB
/
IUserRepository.cs
File metadata and controls
153 lines (132 loc) · 5.51 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
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
using System.Linq.Expressions;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Persistence.Querying;
namespace Umbraco.Cms.Core.Persistence.Repositories;
public interface IUserRepository : IReadWriteQueryRepository<Guid, IUser>
{
/// <summary>
/// Gets the count of items based on a complex query
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
int GetCountByQuery(IQuery<IUser>? query);
/// <summary>
/// Checks if a user with the username exists
/// </summary>
/// <param name="username"></param>
/// <returns></returns>
bool ExistsByUserName(string username);
/// <summary>
/// Returns a user by id
/// </summary>
/// <param name="id"></param>
/// <returns>
/// A cached <see cref="IUser" /> instance
/// </returns>
IUser? Get(int id);
/// <summary>
/// Checks if a user with the login exists
/// </summary>
/// <param name="login"></param>
/// <returns></returns>
bool ExistsByLogin(string login);
/// <summary>
/// Gets a list of <see cref="IUser" /> objects associated with a given group
/// </summary>
/// <param name="groupId">Id of group</param>
IEnumerable<IUser> GetAllInGroup(int groupId);
/// <summary>
/// Gets a list of <see cref="IUser" /> objects not associated with a given group
/// </summary>
/// <param name="groupId">Id of group</param>
IEnumerable<IUser> GetAllNotInGroup(int groupId);
/// <summary>
/// Gets paged user results
/// </summary>
/// <param name="query"></param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="totalRecords"></param>
/// <param name="orderBy"></param>
/// <param name="orderDirection"></param>
/// <param name="includeUserGroups">
/// A filter to only include user that belong to these user groups
/// </param>
/// <param name="excludeUserGroups">
/// A filter to only include users that do not belong to these user groups
/// </param>
/// <param name="userState">Optional parameter to filter by specified user state</param>
/// <param name="filter"></param>
/// <returns></returns>
IEnumerable<IUser> GetPagedResultsByQuery(
IQuery<IUser>? query,
long pageIndex,
int pageSize,
out long totalRecords,
Expression<Func<IUser, object?>> orderBy,
Direction orderDirection = Direction.Ascending,
string[]? includeUserGroups = null,
string[]? excludeUserGroups = null,
UserState[]? userState = null,
IQuery<IUser>? filter = null);
/// <summary>
/// Returns a user by username
/// </summary>
/// <param name="username"></param>
/// <param name="includeSecurityData">
/// This is only used for a shim in order to upgrade to 7.7
/// </param>
/// <returns>
/// A non cached <see cref="IUser" /> instance
/// </returns>
IUser? GetByUsername(string username, bool includeSecurityData);
/// <summary>
/// Gets a user by username for upgrade purposes, this will only return a result if the current runtime state is upgrade.
/// </summary>
/// <remarks>
/// This only resolves the minimum amount of fields required to authorize for an upgrade.
/// We need this to be able to add new columns to the user table.
/// </remarks>
/// <param name="username">The username to find the user by.</param>
/// <returns>An uncached <see cref="IUser"/> instance.</returns>
IUser? GetForUpgradeByUsername(string username) => GetByUsername(username, false);
/// <summary>
/// Gets a user by email for upgrade purposes, this will only return a result if the current runtime state is upgrade.
/// </summary>
/// <remarks>
/// This only resolves the minimum amount of fields required to authorize for an upgrade.
/// We need this to be able to add new columns to the user table.
/// </remarks>
/// <param name="email">The email to find the user by.</param>
/// <returns>An uncached <see cref="IUser"/> instance.</returns>
IUser? GetForUpgradeByEmail(string email) => GetMany().FirstOrDefault(x=>x.Email == email);
/// <summary>
/// Gets a user for upgrade purposes, this will only return a result if the current runtime state is upgrade.
/// </summary>
/// <remarks>
/// This only resolves the minimum amount of fields required to authorize for an upgrade.
/// We need this to be able to add new columns to the user table.
/// </remarks>
/// <param name="id">The id to find the user by.</param>
/// <returns>An uncached <see cref="IUser"/> instance.</returns>
IUser? GetForUpgrade(int id) => Get(id, false);
/// <summary>
/// Returns a user by id
/// </summary>
/// <param name="id"></param>
/// <param name="includeSecurityData">
/// This is only used for a shim in order to upgrade to 7.7
/// </param>
/// <returns>
/// A non cached <see cref="IUser" /> instance
/// </returns>
IUser? Get(int? id, bool includeSecurityData);
IProfile? GetProfile(string username);
IProfile? GetProfile(int id);
IDictionary<UserState, int> GetUserStates();
Guid CreateLoginSession(int? userId, string requestingIpAddress, bool cleanStaleSessions = true);
bool ValidateLoginSession(int userId, Guid sessionId);
int ClearLoginSessions(int userId);
int ClearLoginSessions(TimeSpan timespan);
void ClearLoginSession(Guid sessionId);
}