Skip to content

Commit

Permalink
Added logic to prevent DOM changes on request to prevent error (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrik authored Feb 22, 2021
1 parent 5ce0c4d commit c5ce227
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
<!-- /ko -->

<!-- ko if: !isChangeConfirmed() -->

<form data-bind="submit: changePassword">

<fieldset>
<fieldset data-bind="attr: { disabled: working}">
<div class="form-group">
<label for="password">Password</label>
<input aria-required="true" class="form-control" id="password" name="password"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export class ChangePassword {
userId = `/users/${userId}`;

try {
this.working(true);

if (isCaptcha) {
const resetRequest: ChangePasswordRequest = {
solution: captchaSolution,
Expand Down Expand Up @@ -177,6 +179,8 @@ export class ChangePassword {
errors: errorMessages
};
this.eventManager.dispatchEvent("onValidationErrors", validationReport);
} finally {
this.working(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
<!-- /ko -->

<!-- ko if: !isResetRequested() -->

<form data-bind="submit: resetSubmit">

<fieldset>
<fieldset data-bind="attr: { disabled: working}">
<div class="form-group">
<label for="email">Email</label>
<input aria-required="true" autofocus="autofocus" class="form-control" id="email" name="email"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export class ResetPassword {
}

try {
this.working(true);

if (isCaptcha) {
const resetRequest: ResetRequest = {
solution: captchaSolution,
Expand All @@ -127,8 +129,7 @@ export class ResetPassword {
errors: []
};
this.eventManager.dispatchEvent("onValidationErrors", validationReport);
}
catch (error) {
} catch (error) {
if (isCaptcha) {
WLSPHIP0.reloadHIP();
}
Expand All @@ -151,7 +152,8 @@ export class ResetPassword {
errors: errorMessages
};
this.eventManager.dispatchEvent("onValidationErrors", validationReport);
} finally {
this.working(false);
}

}
}
5 changes: 1 addition & 4 deletions src/components/users/signup/ko/runtime/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
<p id="confirmationMessage">Follow the instructions from the email to verify your account.</p>
<!-- /ko -->


<!-- ko ifnot: working -->
<!-- ko ifnot: isUserRequested -->
<form data-bind="submit: signup">
<fieldset>
<fieldset data-bind="attr: { disabled: working}">
<div class="form-group">
<label for="email">Email</label>
<input aria-required="true" autofocus="autofocus" spellcheck="false" class="form-control" id="email" name="email"
Expand Down Expand Up @@ -72,5 +70,4 @@
</div>
</fieldset>
</form>
<!-- /ko -->
<!-- /ko -->
6 changes: 2 additions & 4 deletions src/components/users/signup/ko/runtime/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ export class Signup {
errors: []
};
this.eventManager.dispatchEvent("onValidationErrors", validationReport);
}
catch (error) {
} catch (error) {
if (isCaptchaRequired) {
WLSPHIP0.reloadHIP();
}
Expand All @@ -247,8 +246,7 @@ export class Signup {
};

this.eventManager.dispatchEvent("onValidationErrors", validationReport);
}
finally {
} finally {
this.working(false);
}
}
Expand Down

0 comments on commit c5ce227

Please sign in to comment.