@@ -11,6 +11,7 @@ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registr
1111import { UMB_SECTION_PATH_PATTERN } from '@umbraco-cms/backoffice/section' ;
1212import { UMB_APP_CONTEXT } from '@umbraco-cms/backoffice/app' ;
1313import { ensurePathEndsWithSlash } from '@umbraco-cms/backoffice/utils' ;
14+ import type { UmbReferenceByUnique } from '@umbraco-cms/backoffice/models' ;
1415
1516export class UmbCurrentUserContext extends UmbContextBase < UmbCurrentUserContext > {
1617 #currentUser = new UmbObjectState < UmbCurrentUserModel | undefined > ( undefined ) ;
@@ -83,6 +84,142 @@ export class UmbCurrentUserContext extends UmbContextBase<UmbCurrentUserContext>
8384 return currentUser ?. isAdmin ?? false ;
8485 }
8586
87+ /**
88+ * Get the allowed sections for the current user
89+ * @returns {Array<string> | undefined } The allowed sections for the current user
90+ */
91+ getAllowedSection ( ) : Array < string > | undefined {
92+ return this . #currentUser. getValue ( ) ?. allowedSections ;
93+ }
94+
95+ /**
96+ * Get the avatar urls for the current user
97+ * @returns {Array<string> | undefined } The avatar urls for the current user
98+ */
99+ getAvatarUrls ( ) : Array < string > | undefined {
100+ return this . #currentUser. getValue ( ) ?. avatarUrls ;
101+ }
102+
103+ /**
104+ * Get the document start node uniques for the current user
105+ * @returns {Array<UmbReferenceByUnique> | undefined } The document start node uniques for the current user
106+ */
107+ getDocumentStartNodeUniques ( ) : Array < UmbReferenceByUnique > | undefined {
108+ return this . #currentUser. getValue ( ) ?. documentStartNodeUniques ;
109+ }
110+
111+ /**
112+ * Get the email for the current user
113+ * @returns {string | undefined } The email for the current user
114+ */
115+ getEmail ( ) : string | undefined {
116+ return this . #currentUser. getValue ( ) ?. email ;
117+ }
118+
119+ /**
120+ * Get the fallback permissions for the current user
121+ * @returns {Array<string> | undefined } The fallback permissions for the current user
122+ */
123+ getFallbackPermissions ( ) : Array < string > | undefined {
124+ return this . #currentUser. getValue ( ) ?. fallbackPermissions ;
125+ }
126+
127+ /**
128+ * Get if the current user has access to all languages
129+ * @returns {boolean | undefined } True if the current user has access to all languages, otherwise false
130+ */
131+ getHasAccessToAllLanguages ( ) : boolean | undefined {
132+ return this . #currentUser. getValue ( ) ?. hasAccessToAllLanguages ;
133+ }
134+
135+ /**
136+ * Get if the current user has access to sensitive data
137+ * @returns {boolean | undefined } True if the current user has access to sensitive data, otherwise false
138+ */
139+ getHasAccessToSensitiveData ( ) : boolean | undefined {
140+ return this . #currentUser. getValue ( ) ?. hasAccessToSensitiveData ;
141+ }
142+
143+ /**
144+ * Get if the current user has document root access
145+ * @returns {boolean | undefined } True if the current user has document root access, otherwise false
146+ */
147+ getHasDocumentRootAccess ( ) : boolean | undefined {
148+ return this . #currentUser. getValue ( ) ?. hasDocumentRootAccess ;
149+ }
150+
151+ /**
152+ * Get if the current user has media root access
153+ * @returns {boolean | undefined } True if the current user has media root access, otherwise false
154+ */
155+ getHasMediaRootAccess ( ) : boolean | undefined {
156+ return this . #currentUser. getValue ( ) ?. hasMediaRootAccess ;
157+ }
158+
159+ /**
160+ * Get if the current user is an admin
161+ * @returns {boolean | undefined } True if the current user is an admin, otherwise false
162+ */
163+ getIsAdmin ( ) : boolean | undefined {
164+ return this . #currentUser. getValue ( ) ?. isAdmin ;
165+ }
166+
167+ /**
168+ * Get the language iso code for the current user
169+ * @returns {string | undefined } The language iso code for the current user
170+ */
171+ getLanguageIsoCode ( ) : string | undefined {
172+ return this . #currentUser. getValue ( ) ?. languageIsoCode ;
173+ }
174+
175+ /**
176+ * Get the languages for the current user
177+ * @returns {Array<string> | undefined } The languages for the current user
178+ */
179+ getLanguages ( ) : Array < string > | undefined {
180+ return this . #currentUser. getValue ( ) ?. languages ;
181+ }
182+
183+ /**
184+ * Get the media start node uniques for the current user
185+ * @returns {Array<UmbReferenceByUnique> | undefined } The media start node uniques for the current user
186+ */
187+ getMediaStartNodeUniques ( ) : Array < UmbReferenceByUnique > | undefined {
188+ return this . #currentUser. getValue ( ) ?. mediaStartNodeUniques ;
189+ }
190+
191+ /**
192+ * Get the name for the current user
193+ * @returns {string | undefined } The name for the current user
194+ */
195+ getName ( ) : string | undefined {
196+ return this . #currentUser. getValue ( ) ?. name ;
197+ }
198+
199+ /**
200+ * Get the permissions for the current user
201+ * @returns {Array<DocumentPermissionPresentationModel | UnknownTypePermissionPresentationModel> | undefined } The permissions for the current user
202+ */
203+ getPermissions ( ) {
204+ return this . #currentUser. getValue ( ) ?. permissions ;
205+ }
206+
207+ /**
208+ * Get the unique for the current user
209+ * @returns {string | undefined } The unique for the current user
210+ */
211+ getUnique ( ) : string | undefined {
212+ return this . #currentUser. getValue ( ) ?. unique ;
213+ }
214+
215+ /**
216+ * Get the user name for the current user
217+ * @returns {string | undefined } The user name for the current user
218+ */
219+ getUserName ( ) : string | undefined {
220+ return this . #currentUser. getValue ( ) ?. userName ;
221+ }
222+
86223 #observeIsAuthorized( ) {
87224 if ( ! this . #authContext) return ;
88225 this . observe ( this . #authContext. isAuthorized , ( isAuthorized ) => {
0 commit comments