Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alkemio-server",
"version": "0.44.2",
"version": "0.44.3",
"description": "Alkemio server, responsible for managing the shared Alkemio platform",
"author": "Alkemio Foundation",
"private": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class OrganizationResolverFields {
async groups(
@Parent() organization: Organization,
@CurrentUser() agentInfo: AgentInfo
) {
): Promise<IUserGroup[] | 'not accessible'> {
if (
await this.isAccessGranted(
organization,
Expand All @@ -51,7 +51,7 @@ export class OrganizationResolverFields {
return await this.organizationService.getUserGroups(organization);
}

throw new ForbiddenException('not accessible', LogContext.COMMUNITY);
return 'not accessible';
}

//@AuthorizationAgentPrivilege(AuthorizationPrivilege.READ)
Expand All @@ -65,7 +65,7 @@ export class OrganizationResolverFields {
@CurrentUser() agentInfo: AgentInfo,
@Parent() organization: Organization,
@Args('ID', { type: () => UUID }) groupID: string
) {
): Promise<IUserGroup | 'not accessible'> {
if (
await this.isAccessGranted(
organization,
Expand All @@ -78,7 +78,7 @@ export class OrganizationResolverFields {
});
}

throw new ForbiddenException('not accessible', LogContext.COMMUNITY);
return 'not accessible';
}

//@AuthorizationAgentPrivilege(AuthorizationPrivilege.READ)
Expand All @@ -91,7 +91,7 @@ export class OrganizationResolverFields {
async associates(
@Parent() organization: Organization,
@CurrentUser() agentInfo: AgentInfo
) {
): Promise<IUser[] | 'not accessible'> {
if (
await this.isAccessGranted(
organization,
Expand All @@ -101,7 +101,7 @@ export class OrganizationResolverFields {
) {
return await this.organizationService.getAssociates(organization);
}
throw new ForbiddenException('not accessible', LogContext.COMMUNITY);
return 'not accessible';
}

@UseGuards(GraphqlGuard)
Expand Down Expand Up @@ -176,7 +176,7 @@ export class OrganizationResolverFields {
async preferences(
@Parent() org: Organization,
@CurrentUser() agentInfo: AgentInfo
) {
): Promise<IPreference[] | 'not accessible'> {
if (
await this.isAccessGranted(org, agentInfo, AuthorizationPrivilege.READ)
) {
Expand All @@ -185,7 +185,7 @@ export class OrganizationResolverFields {
return this.preferenceSetService.getPreferencesOrFail(preferenceSet);
}

throw new ForbiddenException('not accessible', LogContext.COMMUNITY);
return 'not accessible';
}

private async isAccessGranted(
Expand Down
11 changes: 4 additions & 7 deletions src/domain/community/user/user.resolver.fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,13 @@ export class UserResolverFields {
async email(
@Parent() user: User,
@CurrentUser() agentInfo: AgentInfo
): Promise<string> {
): Promise<string | 'not accessible'> {
if (
await this.isAccessGranted(user, agentInfo, AuthorizationPrivilege.READ)
) {
return user.email;
}
throw new ForbiddenException(
`Not able to grant access to agent ${agentInfo} for user ${user}`,
LogContext.COMMUNITY
);
return 'not accessible';
}

@UseGuards(GraphqlGuard)
Expand All @@ -138,13 +135,13 @@ export class UserResolverFields {
async phone(
@Parent() user: User,
@CurrentUser() agentInfo: AgentInfo
): Promise<string> {
): Promise<string | 'not accessible'> {
if (
await this.isAccessGranted(user, agentInfo, AuthorizationPrivilege.READ)
) {
return user.phone;
}
throw new ForbiddenException('not accessible', LogContext.COMMUNITY);
return 'not accessible';
}

@UseGuards(GraphqlGuard)
Expand Down