Table of Contents

Class CurrentUserController

Namespace
Umbraco.Cms.Web.BackOffice.Controllers
Assembly
Umbraco.Web.BackOffice.dll

Controller to back the User.Resource service, used for fetching user data when already authenticated. user.service is currently used for handling authentication

public class CurrentUserController : UmbracoAuthorizedJsonController
Inheritance
CurrentUserController
Inherited Members

Constructors

CurrentUserController(MediaFileManager, IOptionsSnapshot<ContentSettings>, IHostingEnvironment, IImageUrlGenerator, IBackOfficeSecurityAccessor, IUserService, IUmbracoMapper, IBackOfficeUserManager, ILocalizedTextService, AppCaches, IShortStringHelper, IPasswordChanger<BackOfficeIdentityUser>, IUserDataService)

[Obsolete("Use constructor overload that has fileStreamSecurityValidator, scheduled for removal in v14")]
public CurrentUserController(MediaFileManager mediaFileManager, IOptionsSnapshot<ContentSettings> contentSettings, IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IUserService userService, IUmbracoMapper umbracoMapper, IBackOfficeUserManager backOfficeUserManager, ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, IPasswordChanger<BackOfficeIdentityUser> passwordChanger, IUserDataService userDataService)

Parameters

mediaFileManager MediaFileManager
contentSettings IOptionsSnapshot<ContentSettings>
hostingEnvironment IHostingEnvironment
imageUrlGenerator IImageUrlGenerator
backofficeSecurityAccessor IBackOfficeSecurityAccessor
userService IUserService
umbracoMapper IUmbracoMapper
backOfficeUserManager IBackOfficeUserManager
localizedTextService ILocalizedTextService
appCaches AppCaches
shortStringHelper IShortStringHelper
passwordChanger IPasswordChanger<BackOfficeIdentityUser>
userDataService IUserDataService

CurrentUserController(MediaFileManager, IOptionsSnapshot<ContentSettings>, IHostingEnvironment, IImageUrlGenerator, IBackOfficeSecurityAccessor, IUserService, IUmbracoMapper, IBackOfficeUserManager, ILocalizedTextService, AppCaches, IShortStringHelper, IPasswordChanger<BackOfficeIdentityUser>, IUserDataService, IFileStreamSecurityValidator)

[ActivatorUtilitiesConstructor]
public CurrentUserController(MediaFileManager mediaFileManager, IOptionsSnapshot<ContentSettings> contentSettings, IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IUserService userService, IUmbracoMapper umbracoMapper, IBackOfficeUserManager backOfficeUserManager, ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, IPasswordChanger<BackOfficeIdentityUser> passwordChanger, IUserDataService userDataService, IFileStreamSecurityValidator fileStreamSecurityValidator)

Parameters

mediaFileManager MediaFileManager
contentSettings IOptionsSnapshot<ContentSettings>
hostingEnvironment IHostingEnvironment
imageUrlGenerator IImageUrlGenerator
backofficeSecurityAccessor IBackOfficeSecurityAccessor
userService IUserService
umbracoMapper IUmbracoMapper
backOfficeUserManager IBackOfficeUserManager
localizedTextService ILocalizedTextService
appCaches AppCaches
shortStringHelper IShortStringHelper
passwordChanger IPasswordChanger<BackOfficeIdentityUser>
userDataService IUserDataService
fileStreamSecurityValidator IFileStreamSecurityValidator

Methods

GetCurrentUserLinkedLogins()

[Authorize(Policy = "BackOfficeAccess")]
[ValidateAngularAntiForgeryToken]
public Task<Dictionary<string, string>> GetCurrentUserLinkedLogins()

Returns

Task<Dictionary<string, string>>

GetPermissions(int[])

Returns permissions for all nodes passed in for the current user

[HttpPost]
public Dictionary<int, string[]> GetPermissions(int[] nodeIds)

Parameters

nodeIds int[]

Returns

Dictionary<int, string[]>

GetUserData()

public IEnumerable<UserData> GetUserData()

Returns

IEnumerable<UserData>

GetUserTours()

Returns the user's tours

public IEnumerable<UserTourStatus>? GetUserTours()

Returns

IEnumerable<UserTourStatus>

HasPermission(string, int)

Checks a nodes permission for the current user

[HttpGet]
public bool HasPermission(string permissionToCheck, int nodeId)

Parameters

permissionToCheck string
nodeId int

Returns

bool

PostChangePassword(ChangingPasswordModel)

Changes the users password

public Task<ActionResult<ModelWithNotifications<string?>>?> PostChangePassword(ChangingPasswordModel changingPasswordModel)

Parameters

changingPasswordModel ChangingPasswordModel

The changing password model

Returns

Task<ActionResult<ModelWithNotifications<string>>>

If the password is being reset it will return the newly reset password, otherwise will return an empty value

PostSetAvatar(IList<IFormFile>)

[AppendUserModifiedHeader]
public IActionResult PostSetAvatar(IList<IFormFile> file)

Parameters

file IList<IFormFile>

Returns

IActionResult

PostSetInvitedUserPassword(string)

When a user is invited and they click on the invitation link, they will be partially logged in where they can set their username/password

[AllowAnonymous]
[Obsolete("This is no longer used and will be removed in future versions. Use the AuthenticationController.PostSetInvitedUserPassword instead.")]
public Task<ActionResult<UserDetail?>> PostSetInvitedUserPassword(string newPassword)

Parameters

newPassword string

Returns

Task<ActionResult<UserDetail>>

Remarks

This only works when the user is logged in (partially)

See Also

PostSetUserTour(UserTourStatus?)

Saves a tour status for the current user

public IEnumerable<UserTourStatus> PostSetUserTour(UserTourStatus? status)

Parameters

status UserTourStatus

Returns

IEnumerable<UserTourStatus>