This commit is contained in:
Jacob Overgaard
2024-04-02 16:52:22 +02:00
parent ad9bc3ac7d
commit bdf40f2a5f

View File

@@ -2,6 +2,9 @@ import { UMB_CURRENT_USER_CONTEXT } from '../current-user.context.js';
import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
/**
* Check if the current user is the user with the given unique id
*/
export const isCurrentUser = async (host: UmbControllerHost, userUnique: string) => {
const ctrl = new UmbContextConsumerController(host, UMB_CURRENT_USER_CONTEXT);
const currentUserContext = await ctrl.asPromise();
@@ -10,6 +13,9 @@ export const isCurrentUser = async (host: UmbControllerHost, userUnique: string)
return currentUserContext!.isUserCurrentUser(userUnique);
};
/**
* Check if the current user is an admin
*/
export const isCurrentUserAnAdmin = async (host: UmbControllerHost) => {
const ctrl = new UmbContextConsumerController(host, UMB_CURRENT_USER_CONTEXT);
const currentUserContext = await ctrl.asPromise();