File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,15 @@ export class ApiController {
80
80
@Headers ( 'x-application-id' ) applicationId ?,
81
81
) : Promise < any > {
82
82
let startTime = Date . now ( ) ;
83
+
84
+ let status : any , isWhatsApp = false , countryCode , number ;
85
+
86
+ if ( params . phone . includes ( '-' ) ) {
87
+ [ countryCode , number ] = params . phone . split ( '-' ) ;
88
+ params . phone = number ;
89
+ } else {
90
+ number = params . phone ;
91
+ }
83
92
if ( applicationId ) {
84
93
const { total } : { total : number ; users : Array < User > } =
85
94
await this . fusionAuthService . getUsersByString (
@@ -102,16 +111,10 @@ export class ApiController {
102
111
}
103
112
}
104
113
105
- let status : any , isWhatsApp = false , countryCode , number ;
106
114
// Check if phone number contains country code (e.g. 91-1234567890)
107
115
if ( params . deliveryType == 'WA' ) {
108
116
isWhatsApp = true ;
109
- if ( params . phone . includes ( '-' ) ) {
110
- [ countryCode , number ] = params . phone . split ( '-' ) ;
111
- } else {
112
- number = params . phone ;
113
- }
114
- params . phone = number ;
117
+
115
118
status = await this . gupshupWhatsappService . sendWhatsappOTP ( {
116
119
phone : number ,
117
120
template : null ,
Original file line number Diff line number Diff line change @@ -565,6 +565,10 @@ export class ApiService {
565
565
let otp = loginDto . password ;
566
566
let phone = loginDto . loginId ;
567
567
let countryCode , number ;
568
+ if ( phone . includes ( '-' ) ) {
569
+ [ countryCode , number ] = phone . split ( '-' ) ;
570
+ phone = number ;
571
+ }
568
572
const salt = this . configResolverService . getSalt ( loginDto . applicationId ) ;
569
573
let verifyOTPResult ;
570
574
if (
@@ -577,12 +581,7 @@ export class ApiService {
577
581
else
578
582
verifyOTPResult = { status : SMSResponseStatus . failure }
579
583
} else if ( loginDto . deliveryType == 'WA' ) {
580
- if ( phone . includes ( '-' ) ) {
581
- [ countryCode , number ] = phone . split ( '-' ) ;
582
- } else {
583
- number = phone
584
- }
585
- loginDto . loginId = number ;
584
+ loginDto . loginId = phone ;
586
585
const status : any = await this . gupshupWhatsappService . verifyWhatsappOTP ( loginDto . loginId , loginDto . password ) ;
587
586
if ( status . status == 'success' ) {
588
587
verifyOTPResult = { status : SMSResponseStatus . success }
You can’t perform that action at this time.
0 commit comments