add check for the isAdmin property

This commit is contained in:
Jacob Overgaard
2024-04-02 16:52:37 +02:00
parent bdf40f2a5f
commit 8cfb4dec10
2 changed files with 5 additions and 3 deletions

View File

@@ -61,7 +61,7 @@ export class UmbCurrentUserContext extends UmbContextBase<UmbCurrentUserContext>
*/
async isCurrentUserAdmin(): Promise<boolean> {
const currentUser = await firstValueFrom(this.currentUser);
return true; // TODO: Implement this
return currentUser?.isAdmin ?? false;
}
#observeIsAuthorized() {

View File

@@ -1,10 +1,12 @@
import { UmbUserDetailRepository } from '../repository/index.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
/**
* Check if the user is an admin
*/
export const isUserAdmin = async (host: UmbControllerHost, userUnique: string) => {
const repository = new UmbUserDetailRepository(host);
const { data: user } = await repository.requestByUnique(userUnique);
//return user?.isAdmin;
return false;
return user?.isAdmin ?? false;
};