diff --git a/apps/api-gateway/src/ecosystem/ecosystem.controller.ts b/apps/api-gateway/src/ecosystem/ecosystem.controller.ts index d76f1ede2..0ebaa4277 100755 --- a/apps/api-gateway/src/ecosystem/ecosystem.controller.ts +++ b/apps/api-gateway/src/ecosystem/ecosystem.controller.ts @@ -442,28 +442,6 @@ export class EcosystemController { }); } - @Get('/dashboard/summary') - @Roles(OrgRoles.PLATFORM_ADMIN) - @UseGuards(AuthGuard('jwt'), EcosystemRolesGuard) - @ApiBearerAuth() - @ApiOperation({ - summary: 'Get Count for Ecosystem dashboard', - description: 'Get Count for Ecosystem dashboard' - }) - @ApiResponse({ - status: HttpStatus.OK, - description: 'Dashboard count fetched successfully' - }) - async getDashboardCountEcosystem(@Res() res: Response): Promise { - const dashboard = await this.ecosystemService.getDashboardCountEcosystem(); - - return res.status(HttpStatus.OK).json({ - statusCode: HttpStatus.OK, - message: ResponseMessages.ecosystem.success.dashboard, - data: dashboard - }); - } - @Get('/invitation/status') @UseGuards(AuthGuard('jwt')) @ApiBearerAuth() diff --git a/apps/api-gateway/src/platform/platform.controller.ts b/apps/api-gateway/src/platform/platform.controller.ts index 333e01755..be26c628d 100644 --- a/apps/api-gateway/src/platform/platform.controller.ts +++ b/apps/api-gateway/src/platform/platform.controller.ts @@ -335,4 +335,26 @@ export class PlatformController { data: ecosystemStatus }); } + + @Get('/ecosystem/dashboard/summary') + @Roles(OrgRoles.PLATFORM_ADMIN) + @UseGuards(AuthGuard('jwt'), EcosystemRolesGuard) + @ApiBearerAuth() + @ApiOperation({ + summary: 'Get summary for Ecosystem dashboard', + description: 'Get summary for Ecosystem dashboard' + }) + @ApiResponse({ + status: HttpStatus.OK, + description: 'Dashboard count fetched successfully' + }) + async getDashboardCountEcosystem(@Res() res: Response): Promise { + const dashboard = await this.platformService.getDashboardCountEcosystem(); + + return res.status(HttpStatus.OK).json({ + statusCode: HttpStatus.OK, + message: ResponseMessages.ecosystem.success.dashboard, + data: dashboard + }); + } } diff --git a/apps/api-gateway/src/platform/platform.service.ts b/apps/api-gateway/src/platform/platform.service.ts index a2cbfbb8a..e120e014a 100644 --- a/apps/api-gateway/src/platform/platform.service.ts +++ b/apps/api-gateway/src/platform/platform.service.ts @@ -7,7 +7,7 @@ import { GetAllPlatformCredDefsDto } from '../credential-definition/dto/get-all- import { IPlatformCredDefsData } from '@credebl/common/interfaces/cred-def.interface'; import { NATSClient } from '@credebl/common/NATSClient'; import { ClientProxy } from '@nestjs/microservices'; -import { IEcosystemInvitations } from 'apps/ecosystem/interfaces/ecosystem.interfaces'; +import { IEcosystemInvitations, IPlatformDashboardCount } from 'apps/ecosystem/interfaces/ecosystem.interfaces'; import { IPaginationSortingDto, PaginatedResponse } from '@credebl/common/interfaces/interface'; @Injectable() @@ -86,4 +86,8 @@ export class PlatformService extends BaseService { async getEcosystemEnableStatus(): Promise { return this.natsClient.sendNatsMessage(this.platformServiceProxy, 'get-ecosystem-enable-status', {}); } + + async getDashboardCountEcosystem(): Promise { + return this.natsClient.sendNatsMessage(this.platformServiceProxy, 'get-platform-admin-dashboard-count', {}); + } } diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index 28fa83bf7..59f46e429 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -8,7 +8,8 @@ import { UnauthorizedException, InternalServerErrorException, Inject, - HttpException + HttpException, + ForbiddenException } from '@nestjs/common'; import { ClientRegistrationService } from '@credebl/client-registration'; @@ -139,6 +140,9 @@ export class UserService { const clientDetails = await getCredentialsByAlias(clientAlias); + if (process.env.ADMIN_CLIENT_ALIAS === clientAlias) { + throw new ForbiddenException(ResponseMessages.user.error.adminAlias); + } try { const token = await this.clientRegistrationService.getManagementToken( clientDetails.clientId, diff --git a/libs/common/src/response-messages/index.ts b/libs/common/src/response-messages/index.ts index 78383c78d..0153cccdd 100644 --- a/libs/common/src/response-messages/index.ts +++ b/libs/common/src/response-messages/index.ts @@ -33,6 +33,7 @@ export const ResponseMessages = { error: { exists: 'User already exists', profileNotFound: 'User public profile not found', + adminAlias: 'Use of ADMIN alias for user creation is forbidden', notUpdatePlatformSettings: 'Unable to update platform config settings', platformSetttingsNotFound: 'Unable to get platform settings', verificationAlreadySent: 'The verification link has already been sent to your email address',