File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
packages/language/global-contexts Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registr
8
8
import type { ManifestSection } from '@umbraco-cms/backoffice/extension-registry' ;
9
9
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api' ;
10
10
import type { UmbExtensionManifestInitializer } from '@umbraco-cms/backoffice/extension-api' ;
11
+ import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth' ;
11
12
12
13
export class UmbBackofficeContext extends UmbContextBase < UmbBackofficeContext > {
13
14
#activeSectionAlias = new UmbStringState ( undefined ) ;
@@ -26,7 +27,13 @@ export class UmbBackofficeContext extends UmbContextBase<UmbBackofficeContext> {
26
27
this . #allowedSections. setValue ( [ ...sections ] ) ;
27
28
} ) ;
28
29
29
- this . #getVersion( ) ;
30
+ // TODO: We need to ensure this request is called every time the user logs in, but this should be done somewhere across the app and not here [JOV]
31
+ this . consumeContext ( UMB_AUTH_CONTEXT , ( authContext ) => {
32
+ this . observe ( authContext . isAuthorized , ( isAuthorized ) => {
33
+ if ( ! isAuthorized ) return ;
34
+ this . #getVersion( ) ;
35
+ } ) ;
36
+ } ) ;
30
37
}
31
38
32
39
async #getVersion( ) {
Original file line number Diff line number Diff line change 7
7
} from '@umbraco-cms/backoffice/extension-registry' ;
8
8
import { UmbServerExtensionRegistrator } from '@umbraco-cms/backoffice/extension-api' ;
9
9
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element' ;
10
+ import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth' ;
10
11
11
12
import './components/index.js' ;
12
13
@@ -58,7 +59,15 @@ export class UmbBackofficeElement extends UmbLitElement {
58
59
umbExtensionsRegistry . registerMany ( packageModule . extensions ) ;
59
60
} ) ;
60
61
61
- new UmbServerExtensionRegistrator ( this , umbExtensionsRegistry ) . registerPrivateExtensions ( ) ;
62
+ const serverExtensions = new UmbServerExtensionRegistrator ( this , umbExtensionsRegistry ) ;
63
+
64
+ // TODO: We need to ensure this request is called every time the user logs in, but this should be done somewhere across the app and not here [JOV]
65
+ this . consumeContext ( UMB_AUTH_CONTEXT , ( authContext ) => {
66
+ this . observe ( authContext . isAuthorized , ( isAuthorized ) => {
67
+ if ( ! isAuthorized ) return ;
68
+ serverExtensions . registerPrivateExtensions ( ) ;
69
+ } ) ;
70
+ } ) ;
62
71
}
63
72
64
73
render ( ) {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
5
5
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api' ;
6
6
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api' ;
7
7
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api' ;
8
+ import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth' ;
8
9
9
10
// TODO: Make a store for the App Languages.
10
11
// TODO: Implement default language end-point, in progress at backend team, so we can avoid getting all languages.
@@ -28,7 +29,14 @@ export class UmbAppLanguageContext extends UmbContextBase<UmbAppLanguageContext>
28
29
constructor ( host : UmbControllerHost ) {
29
30
super ( host , UMB_APP_LANGUAGE_CONTEXT ) ;
30
31
this . #languageCollectionRepository = new UmbLanguageCollectionRepository ( this ) ;
31
- this . #observeLanguages( ) ;
32
+
33
+ // TODO: We need to ensure this request is called every time the user logs in, but this should be done somewhere across the app and not here [JOV]
34
+ this . consumeContext ( UMB_AUTH_CONTEXT , ( authContext ) => {
35
+ this . observe ( authContext . isAuthorized , ( isAuthorized ) => {
36
+ if ( ! isAuthorized ) return ;
37
+ this . #observeLanguages( ) ;
38
+ } ) ;
39
+ } ) ;
32
40
}
33
41
34
42
setLanguage ( unique : string ) {
You can’t perform that action at this time.
0 commit comments