fix(preferences(js)): show error when passwords don't match

pull/287/head
Francis Lachapelle 2020-07-27 10:20:38 -04:00
parent 2300fe8aab
commit 0e7ce3129c
3 changed files with 13 additions and 4 deletions

View File

@ -242,6 +242,7 @@
"New password" = "New password";
"Confirmation" = "Confirmation";
"Change" = "Change";
"Passwords don't match" = "Passwords don't match";
/* Event+task classifications */
"Default events classification" = "Default events classification";

View File

@ -272,15 +272,17 @@
</label>
<input type="password" sg-no-dirty-check="true" ng-model="app.passwords.newPassword"/>
</md-input-container>
<md-input-container class="md-block" flex="50">
<label><var:string label:value="Confirmation"/>
</label>
<input type="password" sg-no-dirty-check="true" ng-model="app.passwords.newPasswordConfirmation"/>
<input type="password" name="newPasswordConfirmation" sg-no-dirty-check="true" ng-model="app.passwords.newPasswordConfirmation"/>
<div ng-messages="preferencesForm.newPasswordConfirmation.$error">
<div ng-message="newPasswordMismatch"><var:string label:value="Passwords don't match"/></div>
</div>
</md-input-container>
</div>
<div layout="row" layout-align="end center">
<md-button ng-click="app.changePassword()" type="button" ng-disabled="!app.canChangePassword()">
<md-button ng-click="app.changePassword()" type="button" ng-disabled="!app.canChangePassword(preferencesForm)">
<var:string label:value="Change"/>
</md-button>
</div>

View File

@ -462,7 +462,13 @@
return $q.reject('Invalid form');
};
this.canChangePassword = function() {
this.canChangePassword = function(form) {
if (this.passwords.newPasswordConfirmation && this.passwords.newPasswordConfirmation.length &&
this.passwords.newPassword != this.passwords.newPasswordConfirmation) {
form.newPasswordConfirmation.$setValidity('newPasswordMismatch', false);
} else {
form.newPasswordConfirmation.$setValidity('newPasswordMismatch', true);
}
if (this.passwords.newPassword && this.passwords.newPassword.length > 0 &&
this.passwords.newPasswordConfirmation && this.passwords.newPasswordConfirmation.length &&
this.passwords.newPassword == this.passwords.newPasswordConfirmation &&