Interface IUserRepository
Represents a repository for IUser entities.
Namespace: Umbraco.Cms.Core.Persistence.Repositories
Assembly: Umbraco.Core.dll
Syntax
public interface IUserRepository : IReadWriteQueryRepository<Guid, IUser>, IReadRepository<Guid, IUser>, IWriteRepository<IUser>, IQueryRepository<IUser>, IRepository
Methods
View SourceAddClientId(int, string)
Adds a client identifier for a user.
Declaration
void AddClientId(int id, string clientId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The user identifier. |
| string | clientId | The client identifier to add. |
ClearLoginSession(Guid)
Clears a specific login session.
Declaration
void ClearLoginSession(Guid sessionId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | sessionId | The session identifier. |
ClearLoginSessions(int)
Clears all login sessions for a user.
Declaration
int ClearLoginSessions(int userId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | userId | The user identifier. |
Returns
| Type | Description |
|---|---|
| int | The number of sessions cleared. |
ClearLoginSessions(TimeSpan)
Clears login sessions older than the specified timespan.
Declaration
int ClearLoginSessions(TimeSpan timespan)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timespan | The timespan after which sessions are considered stale. |
Returns
| Type | Description |
|---|---|
| int | The number of sessions cleared. |
CreateLoginSession(int?, string, bool)
Creates a login session for a user.
Declaration
Guid CreateLoginSession(int? userId, string requestingIpAddress, bool cleanStaleSessions = true)
Parameters
| Type | Name | Description |
|---|---|---|
| int? | userId | The user identifier. |
| string | requestingIpAddress | The IP address of the requesting client. |
| bool | cleanStaleSessions | Whether to clean stale sessions. |
Returns
| Type | Description |
|---|---|
| Guid | The unique identifier of the created session. |
ExistsByLogin(string)
Checks if a user with the login exists
Declaration
bool ExistsByLogin(string login)
Parameters
| Type | Name | Description |
|---|---|---|
| string | login |
Returns
| Type | Description |
|---|---|
| bool |
ExistsByUserName(string)
Checks if a user with the username exists
Declaration
bool ExistsByUserName(string username)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username |
Returns
| Type | Description |
|---|---|
| bool |
Get(int)
Returns a user by id
Declaration
IUser? Get(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| IUser | A cached IUser instance |
Get(int?, bool)
Returns a user by id
Declaration
IUser? Get(int? id, bool includeSecurityData)
Parameters
| Type | Name | Description |
|---|---|---|
| int? | id | |
| bool | includeSecurityData | This is only used for a shim in order to upgrade to 7.7 |
Returns
| Type | Description |
|---|---|
| IUser | A non cached IUser instance |
GetAllClientIds()
Gets all client identifiers.
Declaration
IEnumerable<string> GetAllClientIds()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | A collection of client identifiers. |
GetAllInGroup(int)
Gets a list of IUser objects associated with a given group
Declaration
IEnumerable<IUser> GetAllInGroup(int groupId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | groupId | Id of group |
Returns
| Type | Description |
|---|---|
| IEnumerable<IUser> |
GetAllNotInGroup(int)
Gets a list of IUser objects not associated with a given group
Declaration
IEnumerable<IUser> GetAllNotInGroup(int groupId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | groupId | Id of group |
Returns
| Type | Description |
|---|---|
| IEnumerable<IUser> |
GetByClientId(string)
Gets a user by their client identifier.
Declaration
IUser? GetByClientId(string clientId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | clientId | The client identifier. |
Returns
| Type | Description |
|---|---|
| IUser | The user if found; otherwise, |
GetByUsername(string, bool)
Returns a user by username
Declaration
IUser? GetByUsername(string username, bool includeSecurityData)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | |
| bool | includeSecurityData | This is only used for a shim in order to upgrade to 7.7 |
Returns
| Type | Description |
|---|---|
| IUser | A non cached IUser instance |
GetClientIds(int)
Gets all client identifiers for a user.
Declaration
IEnumerable<string> GetClientIds(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The user identifier. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | A collection of client identifiers. |
GetCountByQuery(IQuery<IUser>?)
Gets the count of items based on a complex query
Declaration
int GetCountByQuery(IQuery<IUser>? query)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<IUser> | query |
Returns
| Type | Description |
|---|---|
| int |
GetForUpgrade(int)
Gets a user for upgrade purposes, this will only return a result if the current runtime state is upgrade.
Declaration
IUser? GetForUpgrade(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The id to find the user by. |
Returns
| Type | Description |
|---|---|
| IUser | An uncached IUser instance. |
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.
GetForUpgradeByEmail(string)
Gets a user by email for upgrade purposes, this will only return a result if the current runtime state is upgrade.
Declaration
IUser? GetForUpgradeByEmail(string email)
Parameters
| Type | Name | Description |
|---|---|---|
| string | The email to find the user by. |
Returns
| Type | Description |
|---|---|
| IUser | An uncached IUser instance. |
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.
GetForUpgradeByUsername(string)
Gets a user by username for upgrade purposes, this will only return a result if the current runtime state is upgrade.
Declaration
IUser? GetForUpgradeByUsername(string username)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | The username to find the user by. |
Returns
| Type | Description |
|---|---|
| IUser | An uncached IUser instance. |
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.
GetPagedResultsByQuery(IQuery<IUser>?, long, int, out long, Expression<Func<IUser, object?>>, Direction, string[]?, string[]?, UserState[]?, IQuery<IUser>?)
Gets paged user results
Declaration
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)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<IUser> | query | |
| long | pageIndex | |
| int | pageSize | |
| long | totalRecords | |
| Expression<Func<IUser, object>> | orderBy | |
| Direction | orderDirection | |
| string[] | includeUserGroups | A filter to only include user that belong to these user groups |
| string[] | excludeUserGroups | A filter to only include users that do not belong to these user groups |
| UserState[] | userState | Optional parameter to filter by specified user state |
| IQuery<IUser> | filter |
Returns
| Type | Description |
|---|---|
| IEnumerable<IUser> |
GetProfile(int)
Gets a user profile by identifier.
Declaration
IProfile? GetProfile(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The user identifier. |
Returns
| Type | Description |
|---|---|
| IProfile | The user profile if found; otherwise, |
GetProfile(string)
Gets a user profile by username.
Declaration
IProfile? GetProfile(string username)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | The username. |
Returns
| Type | Description |
|---|---|
| IProfile | The user profile if found; otherwise, |
GetUserStates()
Gets the count of users grouped by their state.
Declaration
IDictionary<UserState, int> GetUserStates()
Returns
| Type | Description |
|---|---|
| IDictionary<UserState, int> | A dictionary mapping user states to their counts. |
InvalidateSessionsForRemovedProviders(IEnumerable<string>)
Invalidates sessions for users that aren't associated with the current collection of providers.
Declaration
void InvalidateSessionsForRemovedProviders(IEnumerable<string> currentLoginProviders)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<string> | currentLoginProviders | The names of the currently configured providers. |
RemoveClientId(int, string)
Removes a client identifier from a user.
Declaration
bool RemoveClientId(int id, string clientId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The user identifier. |
| string | clientId | The client identifier to remove. |
Returns
| Type | Description |
|---|---|
| bool |
|
ValidateLoginSession(int, Guid)
Validates a login session for a user.
Declaration
bool ValidateLoginSession(int userId, Guid sessionId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | userId | The user identifier. |
| Guid | sessionId | The session identifier. |
Returns
| Type | Description |
|---|---|
| bool |
|