add check for the isAdmin property
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user