Skip to content

Commit

Permalink
refactor: error messages in common messages
Browse files Browse the repository at this point in the history
Signed-off-by: sanjay-k1910 <[email protected]>
Signed-off-by: bhavanakarwade <[email protected]>
  • Loading branch information
sanjay-k1910 authored and bhavanakarwade committed Feb 27, 2024
1 parent 7fd36c3 commit 52116a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions apps/api-gateway/src/authz/guards/ecosystem-roles.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ export class EcosystemRolesGuard implements CanActivate {
const ecosystemOrgData = await this.ecosystemService.fetchEcosystemOrg(ecosystemId, orgId);

if (!ecosystemOrgData) {
throw new ForbiddenException('Organization does not match');
throw new ForbiddenException(ResponseMessages.organisation.error.orgDoesNotMatch);
}

user.ecosystemOrgRole = ecosystemOrgData['ecosystemRole']['name'];

if (!user.ecosystemOrgRole) {
throw new ForbiddenException('Ecosystem role not match');
throw new ForbiddenException(ResponseMessages.ecosystem.error.ecosystemRoleNotMatch);
}

} else {
throw new BadRequestException('organization & ecosystem is required');
throw new BadRequestException(ResponseMessages.ecosystem.error.orgEcoIdRequired);
}

// Sending user friendly message if a user attempts to access an API that is inaccessible to their role
Expand Down
7 changes: 5 additions & 2 deletions libs/common/src/response-messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export const ResponseMessages = {
invalidUserId:'Invalid format of userId',
invalidInvitationId:'Invalid format for invitation id',
ecosystemIdIsRequired:'ecosystemId is required',
roleNotMatch: 'User does not have access'
roleNotMatch: 'User does not have access',
orgDoesNotMatch: 'Organization does not match'
}
},

Expand Down Expand Up @@ -353,7 +354,9 @@ export const ResponseMessages = {
updateSchemaId: 'Error while updating the schema id',
updateCredDefId: 'Error while updating the credential-definition',
invalidMessage: 'Invalid transaction details. Missing "message" property.',
invalidTransactionMessage: 'Invalid transaction details'
invalidTransactionMessage: 'Invalid transaction details',
ecosystemRoleNotMatch: 'Ecosystem role not match',
orgEcoIdRequired: 'OrgId & EcosystemId is required'
}
},
bulkIssuance: {
Expand Down

0 comments on commit 52116a4

Please sign in to comment.