From 66f412723e210abdbdc89f9a8daec29fbb9d8645 Mon Sep 17 00:00:00 2001 From: Amruth Vamshi Date: Mon, 4 Dec 2023 11:13:35 +0530 Subject: [PATCH 1/5] 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 4dabdb033d99e02be3ed829421d35978c9d9d713 Mon Sep 17 00:00:00 2001 From: Amruth Vamshi Date: Thu, 18 Jan 2024 14:03:29 +0530 Subject: [PATCH 2/5] 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..2e4da4a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,7 +19,7 @@ async function bootstrap() { SwaggerModule.setup('swagger', app, document); // add security headers app.use(helmet()); - + app.set('trust proxy', 1); // enable cors app.enableCors({ origin: process.env.CORS_ALLOWED_ORIGINS?.split(/\s*,\s*/) ?? '*', From c599f8d758851a1a1a0600b4b75eec460e8fcdbb Mon Sep 17 00:00:00 2001 From: Amruth-Vamshi <130033232+Amruth-Vamshi@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:23:50 +0530 Subject: [PATCH 3/5] Fix: if default opt is enabled. checking OTP for other users through normal flow. --- src/api/api.service.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/api/api.service.ts b/src/api/api.service.ts index 2753c96..180565f 100644 --- a/src/api/api.service.ts +++ b/src/api/api.service.ts @@ -544,6 +544,12 @@ export class ApiService { else verifyOTPResult = {status: SMSResponseStatus.failure} } + else { + verifyOTPResult = await this.otpService.verifyOTP({ + phone: loginDto.loginId, + otp: loginDto.password, // existing OTP + }); + } } else { verifyOTPResult = await this.otpService.verifyOTP({ phone: loginDto.loginId, From 67c9e412e14fb648b4acd458c214e6b577176111 Mon Sep 17 00:00:00 2001 From: Amruth-Vamshi <130033232+Amruth-Vamshi@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:59:31 +0530 Subject: [PATCH 4/5] removed trust proxy --- src/main.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 2e4da4a..c640955 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,7 +19,6 @@ async function bootstrap() { SwaggerModule.setup('swagger', app, document); // add security headers app.use(helmet()); - app.set('trust proxy', 1); // enable cors app.enableCors({ origin: process.env.CORS_ALLOWED_ORIGINS?.split(/\s*,\s*/) ?? '*', From bacbd70420a72df1e93ca27d2a7c6818a20bffc5 Mon Sep 17 00:00:00 2001 From: Amruth-Vamshi <130033232+Amruth-Vamshi@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:21:01 +0530 Subject: [PATCH 5/5] updated loginWithOtp comments --- src/api/api.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/api.service.ts b/src/api/api.service.ts index 180565f..c4fbdac 100644 --- a/src/api/api.service.ts +++ b/src/api/api.service.ts @@ -525,7 +525,9 @@ export class ApiService { async loginWithOtp(loginDto: LoginDto, authHeader: null | string): Promise { /* Execution flow - 1. Verify OTP + 1. Check if ALLOW_DEFAULT_OTP is set to true. + 2. If true check if user number is listed in DEFAULT_OTP_USERS, if yes send sucess if OTP matches. + 3. else; Verify OTP via fusion auth. 2. If invalid OTP, throw error; else continue with next steps 3. Check if user exists for the given applicationId. 3.1. If existing user, reset the password.