feat(preferences): Improve TOTP - add validation code in preferences before saving to ensure user add qr code in totp application

This commit is contained in:
smizrahi
2023-01-04 17:37:46 +01:00
parent 7d72fe1281
commit 0bd530ab64
5 changed files with 91 additions and 1 deletions
@@ -456,8 +456,10 @@
});
}
if (sendForm)
if (sendForm) {
var self = this;
return this.preferences.$save().then(function(data) {
self.preferences.defaults.totpVerificationCode = ''
if (!options || !options.quick) {
$mdToast.show(
$mdToast.simple()
@@ -466,11 +468,20 @@
.hideDelay(2000));
form.$setPristine();
}
}).catch(function(e) {
if (485 == e.status) {
form.totpVerificationCode.$setValidity('invalidTotpCode', false);
}
});
}
return $q.reject('Invalid form');
};
this.resetTotpVerificationCode = function(form) {
form.totpVerificationCode.$setValidity('invalidTotpCode', true);
}
this.canChangePassword = function(form) {
if (this.passwords.newPasswordConfirmation && this.passwords.newPasswordConfirmation.length &&
this.passwords.newPassword != this.passwords.newPasswordConfirmation) {