Skip to content

Commit 5d11765

Browse files
authored
Merge pull request #1774 from umbraco/bugfix/global-requests-retry
Retry requests after log in
2 parents 5335f03 + f6123d4 commit 5d11765

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/apps/backoffice/backoffice.context.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registr
88
import type { ManifestSection } from '@umbraco-cms/backoffice/extension-registry';
99
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
1010
import type { UmbExtensionManifestInitializer } from '@umbraco-cms/backoffice/extension-api';
11+
import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';
1112

1213
export class UmbBackofficeContext extends UmbContextBase<UmbBackofficeContext> {
1314
#activeSectionAlias = new UmbStringState(undefined);
@@ -26,7 +27,13 @@ export class UmbBackofficeContext extends UmbContextBase<UmbBackofficeContext> {
2627
this.#allowedSections.setValue([...sections]);
2728
});
2829

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+
});
3037
}
3138

3239
async #getVersion() {

src/apps/backoffice/backoffice.element.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@umbraco-cms/backoffice/extension-registry';
88
import { UmbServerExtensionRegistrator } from '@umbraco-cms/backoffice/extension-api';
99
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
10+
import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';
1011

1112
import './components/index.js';
1213

@@ -58,7 +59,15 @@ export class UmbBackofficeElement extends UmbLitElement {
5859
umbExtensionsRegistry.registerMany(packageModule.extensions);
5960
});
6061

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+
});
6271
}
6372

6473
render() {

src/packages/language/global-contexts/app-language.context.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
55
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
66
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
77
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
8+
import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';
89

910
// TODO: Make a store for the App Languages.
1011
// 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>
2829
constructor(host: UmbControllerHost) {
2930
super(host, UMB_APP_LANGUAGE_CONTEXT);
3031
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+
});
3240
}
3341

3442
setLanguage(unique: string) {

0 commit comments

Comments
 (0)