Skip to content

Commit

Permalink
Merge bacbd70 into 828254b
Browse files Browse the repository at this point in the history
  • Loading branch information
Amruth-Vamshi committed Mar 13, 2024
2 parents 828254b + bacbd70 commit cbac63b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/api/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ export class ApiService {

async loginWithOtp(loginDto: LoginDto, authHeader: null | string): Promise<SignupResponse> {
/* 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.
Expand All @@ -544,6 +546,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,
Expand All @@ -564,11 +572,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;
}
});
}
Expand All @@ -581,7 +590,7 @@ export class ApiService {
registrations: [
{
applicationId: loginDto.applicationId,
roles: loginDto.roles ?? [],
roles: registeredRoles,
id: registrationId,
},
],
Expand Down
1 change: 0 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ async function bootstrap() {
SwaggerModule.setup('swagger', app, document);
// add security headers
app.use(helmet());

// enable cors
app.enableCors({
origin: process.env.CORS_ALLOWED_ORIGINS?.split(/\s*,\s*/) ?? '*',
Expand Down

0 comments on commit cbac63b

Please sign in to comment.