diff --git a/webapp/src/app/api/model/accountProfile.ts b/webapp/src/app/api/model/accountProfile.ts index b40876f2..956d43aa 100644 --- a/webapp/src/app/api/model/accountProfile.ts +++ b/webapp/src/app/api/model/accountProfile.ts @@ -14,6 +14,7 @@ export interface AccountProfile { email: string; name: string; role: UserRole; + permissions?: Array; organization_id: string; organization_name: string; deleted: boolean; diff --git a/webapp/src/app/shared/services/credential.service.ts b/webapp/src/app/shared/services/credential.service.ts index e70311a2..7613806a 100644 --- a/webapp/src/app/shared/services/credential.service.ts +++ b/webapp/src/app/shared/services/credential.service.ts @@ -83,6 +83,22 @@ export class CredentialService { () => this.accountProfile()?.organization_name ?? '', ); + public readonly permissions = computed( + () => this.accountProfile()?.permissions ?? [], + ); + + public readonly canReadAccounts = computed(() => + this.permissions().includes('READ_ACCOUNTS'), + ); + + public readonly canManageAccounts = computed(() => + this.permissions().includes('MANAGE_ACCOUNTS'), + ); + + public readonly canManageOrganizations = computed(() => + this.permissions().includes('MANAGE_ORGANIZATIONS'), + ); + public readonly realAccountId = computed( () => this.accessToken()?.real_account_id ?? '', );