From 66f412723e210abdbdc89f9a8daec29fbb9d8645 Mon Sep 17 00:00:00 2001 From: Amruth Vamshi Date: Mon, 4 Dec 2023 11:13:35 +0530 Subject: [PATCH 1/2] Fixed: user registered roles being reset. --- src/api/api.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/api.service.ts b/src/api/api.service.ts index 65f36c6..2753c96 100644 --- a/src/api/api.service.ts +++ b/src/api/api.service.ts @@ -564,11 +564,12 @@ export class ApiService { authHeader, ); if (statusFA === FAStatus.USER_EXISTS) { - let registrationId = null; + let registrationId = null, registeredRoles = []; if (user.registrations) { user.registrations.map((item) => { if (item.applicationId == loginDto.applicationId) { registrationId = item.id; + registeredRoles = item.roles; } }); } @@ -581,7 +582,7 @@ export class ApiService { registrations: [ { applicationId: loginDto.applicationId, - roles: loginDto.roles ?? [], + roles: registeredRoles, id: registrationId, }, ], From 95f8739990314435c1a16cc734acc20e6f6a46cf Mon Sep 17 00:00:00 2001 From: Amruth Vamshi Date: Thu, 18 Jan 2024 14:02:00 +0530 Subject: [PATCH 2/2] set trust proxy --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 1701912..18bd3b8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,4 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; - import { AppModule } from './app.module'; import { NestFactory } from '@nestjs/core'; import * as Sentry from '@sentry/node'; @@ -19,6 +18,7 @@ async function bootstrap() { SwaggerModule.setup('swagger', app, document); // add security headers app.use(helmet()); + app.set('trust proxy', 1); // enable cors app.enableCors({