Class UserExtensions
Provides extension methods for the IUser interface related to content/media access, avatar URLs, and start node calculations.
Inheritance
Namespace: Umbraco.Cms.Core.Models
Assembly: Umbraco.Core.dll
Syntax
public static class UserExtensions
Methods
View SourceCalculateAllowedLanguageIds(IUser, ILocalizationService)
Calculate start nodes, combining groups' and user's, and excluding what's in the bin
Declaration
public static int[] CalculateAllowedLanguageIds(this IUser user, ILocalizationService localizationService)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | |
| ILocalizationService | localizationService |
Returns
| Type | Description |
|---|---|
| int[] |
CalculateContentStartNodeIds(IUser, IEntityService, AppCaches)
Calculates the content start node IDs for the user, combining user and group start nodes.
Declaration
public static int[]? CalculateContentStartNodeIds(this IUser user, IEntityService entityService, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to calculate start nodes for. |
| IEntityService | entityService | The entity service. |
| AppCaches | appCaches | The application caches. |
Returns
| Type | Description |
|---|---|
| int[] | An array of content start node IDs, or |
CalculateMediaStartNodeIds(IUser, IEntityService, AppCaches)
Calculate start nodes, combining groups' and user's, and excluding what's in the bin
Declaration
public static int[]? CalculateMediaStartNodeIds(this IUser user, IEntityService entityService, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | |
| IEntityService | entityService | |
| AppCaches | appCaches |
Returns
| Type | Description |
|---|---|
| int[] |
GetContentStartNodePaths(IUser, IEntityService, AppCaches)
Gets the content start node paths for the user.
Declaration
public static string[]? GetContentStartNodePaths(this IUser user, IEntityService entityService, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to get paths for. |
| IEntityService | entityService | The entity service. |
| AppCaches | appCaches | The application caches. |
Returns
| Type | Description |
|---|---|
| string[] | An array of content start node paths, or |
GetMediaStartNodePaths(IUser, IEntityService, AppCaches)
Gets the media start node paths for the user.
Declaration
public static string[]? GetMediaStartNodePaths(this IUser user, IEntityService entityService, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to get paths for. |
| IEntityService | entityService | The entity service. |
| AppCaches | appCaches | The application caches. |
Returns
| Type | Description |
|---|---|
| string[] | An array of media start node paths, or |
GetUserAvatarUrls(IUser, IAppCache, MediaFileManager, IImageUrlGenerator)
Tries to lookup the user's Gravatar to see if the endpoint can be reached, if so it returns the valid URL
Declaration
public static string[] GetUserAvatarUrls(this IUser user, IAppCache cache, MediaFileManager mediaFileManager, IImageUrlGenerator imageUrlGenerator)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | |
| IAppCache | cache | |
| MediaFileManager | mediaFileManager | |
| IImageUrlGenerator | imageUrlGenerator |
Returns
| Type | Description |
|---|---|
| string[] | A list of 5 different sized avatar URLs |
HasAccessToSensitiveData(IUser)
Determines whether this user has access to view sensitive data
Declaration
public static bool HasAccessToSensitiveData(this IUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user |
Returns
| Type | Description |
|---|---|
| bool |
HasContentPathAccess(IUser, IUmbracoEntity, IEntityService, AppCaches)
Determines whether the user has content path access to the specified entity.
Declaration
public static bool HasContentPathAccess(this IUser user, IUmbracoEntity entity, IEntityService entityService, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to check. |
| IUmbracoEntity | entity | The entity to check access for. |
| IEntityService | entityService | The entity service. |
| AppCaches | appCaches | The application caches. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
HasMediaPathAccess(IUser, IUmbracoEntity, IEntityService, AppCaches)
Determines whether the user has media path access to the specified entity.
Declaration
public static bool HasMediaPathAccess(this IUser user, IUmbracoEntity entity, IEntityService entityService, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to check. |
| IUmbracoEntity | entity | The entity to check access for. |
| IEntityService | entityService | The entity service. |
| AppCaches | appCaches | The application caches. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
HasPathAccess(IUser, IContent, IEntityService, AppCaches)
Determines whether the user has path access to the specified content item.
Declaration
public static bool HasPathAccess(this IUser user, IContent content, IEntityService entityService, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to check. |
| IContent | content | The content item to check access for. |
| IEntityService | entityService | The entity service. |
| AppCaches | appCaches | The application caches. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
HasPathAccess(IUser, IMedia?, IEntityService, AppCaches)
Determines whether the user has path access to the specified media item.
Declaration
public static bool HasPathAccess(this IUser user, IMedia? media, IEntityService entityService, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to check. |
| IMedia | media | The media item to check access for. |
| IEntityService | entityService | The entity service. |
| AppCaches | appCaches | The application caches. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |