diff --git a/src/Umbraco.Web.UI.Client/src/shared/auth/auth.context.ts b/src/Umbraco.Web.UI.Client/src/shared/auth/auth.context.ts index f6ffa51e6d..b9c00be403 100644 --- a/src/Umbraco.Web.UI.Client/src/shared/auth/auth.context.ts +++ b/src/Umbraco.Web.UI.Client/src/shared/auth/auth.context.ts @@ -11,6 +11,7 @@ export class UmbAuthContext implements IUmbAuth { #currentUser = new UmbObjectState(undefined); readonly currentUser = this.#currentUser.asObservable(); readonly isLoggedIn = new ReplaySubject(1); + readonly languageIsoCode = this.#currentUser.asObservablePart((user) => user?.languageIsoCode ?? 'en-us'); #host; #authFlow; @@ -33,8 +34,6 @@ export class UmbAuthContext implements IUmbAuth { async fetchCurrentUser(): Promise { const { data } = await tryExecuteAndNotify(this.#host, UserResource.getUserCurrent()); - if (!data) return; - this.#currentUser.next(data); return data; diff --git a/src/Umbraco.Web.UI.Client/src/shared/auth/auth.interface.ts b/src/Umbraco.Web.UI.Client/src/shared/auth/auth.interface.ts index 284388fe41..b70031f8d7 100644 --- a/src/Umbraco.Web.UI.Client/src/shared/auth/auth.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/shared/auth/auth.interface.ts @@ -23,6 +23,11 @@ export interface IUmbAuth { */ get currentUser(): Observable; + /** + * Get the current user's language ISO code. + */ + languageIsoCode: Observable; + /** * Make a server request for the current user and save the state */