Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ export class RegisterComponent extends BaseComponent implements AfterViewInit, O
return;
}
const currentEmail = emailControl.value;
const isIdentifierChanged = currentEmail !== this.lastSentEmail;
if (isResend && currentEmail !== this.lastSentEmail) {
this.stopResendTimer('email');
this.canResendEmailOtp = true;
Expand All @@ -644,6 +645,7 @@ export class RegisterComponent extends BaseComponent implements AfterViewInit, O
request: {
referenceId: this.referenceId(),
identifier: currentEmail,
useRetry: isResend && !isIdentifierChanged,
},
})
);
Expand All @@ -664,6 +666,7 @@ export class RegisterComponent extends BaseComponent implements AfterViewInit, O
return;
}
const currentMobile = mobileControl.value;
const isIdentifierChanged = currentMobile !== this.lastSentMobileNumber;
if (isResend && currentMobile !== this.lastSentMobileNumber) {
this.stopResendTimer('mobile');
this.canResendOtp = true;
Expand All @@ -678,6 +681,7 @@ export class RegisterComponent extends BaseComponent implements AfterViewInit, O
request: {
referenceId: this.referenceId(),
identifier: currentMobile,
useRetry: isResend && !isIdentifierChanged,
},
})
);
Expand Down
1 change: 1 addition & 0 deletions apps/36-blocks-widget/src/app/otp/model/otp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface ISendOtpReq {
origin?: string;
variables?: any;
authToken?: string;
useRetry?: boolean;
}

export interface IRetryOtpReq extends ISendOtpReq {
Expand Down
6 changes: 6 additions & 0 deletions apps/36-blocks-widget/src/app/otp/service/otp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export class OtpService {
const body = { identifier: request.identifier ?? request.mobile };
return this.http.post<OtpResModel>(otpVerificationUrls.sendOtp(this.baseUrl), body, this.options);
}

public retryOtp(request: ISendOtpReq): Observable<OtpResModel> {
this.setOtpRequestHeaders(request);
const body = { identifier: request.identifier ?? request.mobile };
return this.http.post<OtpResModel>(otpVerificationUrls.retryOtp(this.baseUrl), body, this.options);
}
public verifyOtpV2(request: IVerifyOtpV2Req): Observable<any> {
this.setOtpRequestHeaders(request);
const body = {
Expand Down
1 change: 1 addition & 0 deletions apps/36-blocks-widget/src/app/otp/service/urls/otp-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createUrl } from '@proxy/service';
export const otpVerificationUrls = {
getWidgetData: (baseUrl) => createUrl(baseUrl, ':referenceId/widget'),
sendOtp: (baseUrl) => createUrl(baseUrl, 'otp/send'),
retryOtp: (baseUrl) => createUrl(baseUrl, 'otp/retry'),
verifyOtpV2: (baseUrl) => createUrl(baseUrl, 'otp/verify'),
verifyOtp: (baseUrl) => createUrl(baseUrl, 'widget/verifyOtp'),
resend: (baseUrl) => createUrl(baseUrl, 'widget/retryOtp'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export class OtpEffects {
this.actions$.pipe(
ofType(otpActions.sendOtpAction),
switchMap((p) => {
return this.otpService.sendOtp(p.request).pipe(
const otpRequest$ = p.request?.useRetry
? this.otpService.retryOtp(p.request)
: this.otpService.sendOtp(p.request);
return otpRequest$.pipe(
map((res: OtpResModel) => {
if (res.type !== 'error') {
return otpActions.sendOtpActionComplete({
Expand Down
Loading