From fe4ef62977b20a3058b797a6df072cdfd0b33eee Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 22 Oct 2024 09:28:39 +0200 Subject: [PATCH] add methods to get current user data --- .../user/current-user/current-user.context.ts | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/current-user.context.ts b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/current-user.context.ts index b6836e70b7..4a18f94086 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/current-user.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/current-user.context.ts @@ -83,6 +83,74 @@ export class UmbCurrentUserContext extends UmbContextBase return currentUser?.isAdmin ?? false; } + getAllowedSection() { + return this.#currentUser.getValue()?.allowedSections; + } + + getAvatarUrls() { + return this.#currentUser.getValue()?.avatarUrls; + } + + getDocumentStartNodeUniques() { + return this.#currentUser.getValue()?.documentStartNodeUniques; + } + + getEmail() { + return this.#currentUser.getValue()?.email; + } + + getFallbackPermissions() { + return this.#currentUser.getValue()?.fallbackPermissions; + } + + getHasAccessToAllLanguages() { + return this.#currentUser.getValue()?.hasAccessToAllLanguages; + } + + getHasAccessToSensitiveData() { + return this.#currentUser.getValue()?.hasAccessToSensitiveData; + } + + getHasDocumentRootAccess() { + return this.#currentUser.getValue()?.hasDocumentRootAccess; + } + + getHasMediaRootAccess() { + return this.#currentUser.getValue()?.hasMediaRootAccess; + } + + getIsAdmin() { + return this.#currentUser.getValue()?.isAdmin; + } + + getLanguageIsoCode() { + return this.#currentUser.getValue()?.languageIsoCode; + } + + getLanguages() { + return this.#currentUser.getValue()?.languages; + } + + getMediaStartNodeUniques() { + return this.#currentUser.getValue()?.mediaStartNodeUniques; + } + + getName() { + return this.#currentUser.getValue()?.name; + } + + getPermissions() { + return this.#currentUser.getValue()?.permissions; + } + + getUnique() { + return this.#currentUser.getValue()?.unique; + } + + getUserName() { + return this.#currentUser.getValue()?.userName; + } + #observeIsAuthorized() { if (!this.#authContext) return; this.observe(this.#authContext.isAuthorized, (isAuthorized) => {