Class BackOfficeSecurity
Inheritance
System.Object
Namespace: Umbraco.Cms.Web.Common.Security
Assembly: Umbraco.Web.Common.dll
Syntax
public class BackOfficeSecurity : IBackOfficeSecurity
Constructors
View SourceBackOfficeSecurity(IUserService, IHttpContextAccessor)
Declaration
public BackOfficeSecurity(IUserService userService, IHttpContextAccessor httpContextAccessor)
Parameters
| Type | Name | Description |
|---|---|---|
| IUserService | userService | |
| Microsoft.AspNetCore.Http.IHttpContextAccessor | httpContextAccessor |
Properties
View SourceCurrentUser
Gets the current user.
Declaration
public IUser CurrentUser { get; }
Property Value
| Type | Description |
|---|---|
| IUser | The current user that has been authenticated for the request. |
Remarks
If authentication hasn't taken place this will be null.
Methods
View SourceGetUserId()
Gets the current user's id.
Declaration
public Attempt<int> GetUserId()
Returns
| Type | Description |
|---|---|
| Attempt<System.Int32> | The current user's Id that has been authenticated for the request. |
Remarks
If authentication hasn't taken place this will be unsuccessful.
IsAuthenticated()
Ensures that a back office user is logged in
Declaration
public bool IsAuthenticated()
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
This does not force authentication, that must be done before calls to this are made.
UserHasSectionAccess(String, IUser)
Checks if the specified user as access to the app
Declaration
public bool UserHasSectionAccess(string section, IUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | section | |
| IUser | user |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
If authentication hasn't taken place this will be unsuccessful.