in src/components/users/reset-password/ko/runtime/reset-password.ts [79:136]
public async resetSubmit(): Promise<void> {
const captchaIsRequired = this.requireHipCaptcha();
const validationGroup = { email: this.email };
if (captchaIsRequired) {
if (!this.setCaptchaValidation) {
this.logger.trackEvent("CaptchaValidation", { message: "Captcha failed to initialize." });
dispatchErrors(this.eventManager, ErrorSources.resetpassword, [ValidationMessages.captchaNotInitialized]);
return;
}
validationGroup["captcha"] = this.captcha;
this.setCaptchaValidation(this.captcha);
}
const result = validation.group(validationGroup);
const clientErrors = result();
if (clientErrors.length > 0) {
result.showAllMessages();
dispatchErrors(this.eventManager, ErrorSources.resetpassword, clientErrors);
return;
}
try {
this.working(true);
if (captchaIsRequired) {
const captchaRequestData = this.captchaData();
const resetRequest: ResetRequest = {
challenge: captchaRequestData.challenge,
solution: captchaRequestData.solution?.solution,
flowId: captchaRequestData.solution?.flowId,
token: captchaRequestData.solution?.token,
type: captchaRequestData.solution?.type,
email: this.email()
};
await this.backendService.sendResetRequest(resetRequest);
}
else {
await this.usersService.createResetPasswordRequest(this.email());
}
this.isResetRequested(true);
dispatchErrors(this.eventManager, ErrorSources.resetpassword, []);
}
catch (error) {
if (captchaIsRequired) {
await this.refreshCaptcha();
}
parseAndDispatchError(this.eventManager, ErrorSources.resetpassword, error, this.logger, undefined, detail => `${detail.target}: ${detail.message} \n`);
}
finally {
this.working(false);
}
}