@@ -525,7 +525,9 @@ export class ApiService {
525
525
526
526
async loginWithOtp ( loginDto : LoginDto , authHeader : null | string ) : Promise < SignupResponse > {
527
527
/* Execution flow
528
- 1. Verify OTP
528
+ 1. Check if ALLOW_DEFAULT_OTP is set to true.
529
+ 2. If true check if user number is listed in DEFAULT_OTP_USERS, if yes send sucess if OTP matches.
530
+ 3. else; Verify OTP via fusion auth.
529
531
2. If invalid OTP, throw error; else continue with next steps
530
532
3. Check if user exists for the given applicationId.
531
533
3.1. If existing user, reset the password.
@@ -544,6 +546,12 @@ export class ApiService {
544
546
else
545
547
verifyOTPResult = { status : SMSResponseStatus . failure }
546
548
}
549
+ else {
550
+ verifyOTPResult = await this . otpService . verifyOTP ( {
551
+ phone : loginDto . loginId ,
552
+ otp : loginDto . password , // existing OTP
553
+ } ) ;
554
+ }
547
555
} else {
548
556
verifyOTPResult = await this . otpService . verifyOTP ( {
549
557
phone : loginDto . loginId ,
@@ -564,11 +572,12 @@ export class ApiService {
564
572
authHeader ,
565
573
) ;
566
574
if ( statusFA === FAStatus . USER_EXISTS ) {
567
- let registrationId = null ;
575
+ let registrationId = null , registeredRoles = [ ] ;
568
576
if ( user . registrations ) {
569
577
user . registrations . map ( ( item ) => {
570
578
if ( item . applicationId == loginDto . applicationId ) {
571
579
registrationId = item . id ;
580
+ registeredRoles = item . roles ;
572
581
}
573
582
} ) ;
574
583
}
@@ -581,7 +590,7 @@ export class ApiService {
581
590
registrations : [
582
591
{
583
592
applicationId : loginDto . applicationId ,
584
- roles : loginDto . roles ?? [ ] ,
593
+ roles : registeredRoles ,
585
594
id : registrationId ,
586
595
} ,
587
596
] ,
0 commit comments