use current user context

This commit is contained in:
Mads Rasmussen
2023-11-10 10:41:11 +01:00
parent 2210571476
commit 13ca23f86e
2 changed files with 9 additions and 5 deletions

View File

@@ -1,13 +1,13 @@
import { IUmbAuth, UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';
import { UMB_CURRENT_USER_CONTEXT } from '../current-user.context.js';
import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api';
import { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
export const isCurrentUser = async (host: UmbControllerHost, userId: string) => {
let authContext: IUmbAuth | undefined = undefined;
let currentUserContext: typeof UMB_CURRENT_USER_CONTEXT.TYPE | undefined;
await new UmbContextConsumerController(host, UMB_AUTH_CONTEXT, (context) => {
authContext = context;
await new UmbContextConsumerController(host, UMB_CURRENT_USER_CONTEXT, (context) => {
currentUserContext = context;
}).asPromise();
return await authContext!.isUserCurrentUser(userId);
return await currentUserContext!.isUserCurrentUser(userId);
};

View File

@@ -1,4 +1,8 @@
import { Observable } from '@umbraco-cms/backoffice/external/rxjs';
export interface IUmbAuth {
isLoggedIn: Observable<boolean>;
/**
* Initiates the login flow.
*/