1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

Password rules for registration and change.

This commit is contained in:
Kyle Spearrin 2016-10-03 23:21:23 -04:00
parent 70dc680dc9
commit abe6ff074b
2 changed files with 28 additions and 1 deletions

View File

@ -11,8 +11,21 @@ angular
$scope.registerPromise = null;
$scope.register = function (form) {
var error = false;
if ($scope.model.masterPassword.length < 8 || !/[a-z]/i.test($scope.model.masterPassword) ||
/^[a-zA-Z]*$/.test($scope.model.masterPassword)) {
validationService.addError(form, 'MasterPassword',
'Master password must be at least 8 characters long and contain at least 1 letter and 1 number ' +
'or special character.', true);
error = true;
}
if ($scope.model.masterPassword !== $scope.model.confirmMasterPassword) {
validationService.addError(form, 'ConfirmMasterPassword', 'Master password confirmation does not match.', true);
error = true;
}
if (error) {
return;
}

View File

@ -5,8 +5,22 @@
cryptoService, authService, cipherService, validationService, $q, toastr, $analytics) {
$analytics.eventTrack('settingsChangePasswordController', { category: 'Modal' });
$scope.save = function (model, form) {
var error = false;
if ($scope.model.newMasterPassword.length < 8 || !/[a-z]/i.test($scope.model.newMasterPassword) ||
/^[a-zA-Z]*$/.test($scope.model.newMasterPassword)) {
validationService.addError(form, 'NewMasterPasswordHash',
'Master password must be at least 8 characters long and contain at least 1 letter and 1 number ' +
'or special character.', true);
error = true;
}
if ($scope.model.newMasterPassword !== $scope.model.confirmNewMasterPassword) {
validationService.addError(form, 'ConfirmNewMasterPassword', 'New master password confirmation does not match.', true);
validationService.addError(form, 'ConfirmNewMasterPasswordHash',
'New master password confirmation does not match.', true);
error = true;
}
if (error) {
return;
}