1
0
mirror of https://github.com/bitwarden/web synced 2025-12-13 06:43:31 +00:00

reorganize project folder structure and remove asp.net dependency

This commit is contained in:
Kyle Spearrin
2016-11-30 23:50:00 -05:00
parent a5b8e703fc
commit b72a52232d
94 changed files with 76 additions and 330 deletions

View File

@@ -0,0 +1,40 @@
angular
.module('bit.directives')
.directive('masterPassword', function (cryptoService, authService) {
return {
require: 'ngModel',
restrict: 'A',
link: function (scope, elem, attr, ngModel) {
var profile = authService.getUserProfile();
if (!profile) {
return;
}
// For DOM -> model validation
ngModel.$parsers.unshift(function (value) {
if (!value) {
return undefined;
}
var key = cryptoService.makeKey(value, profile.email, true);
var valid = key === cryptoService.getKey(true);
ngModel.$setValidity('masterPassword', valid);
return valid ? value : undefined;
});
// For model -> DOM validation
ngModel.$formatters.unshift(function (value) {
if (!value) {
return undefined;
}
var key = cryptoService.makeKey(value, profile.email, true);
var valid = key === cryptoService.getKey(true);
ngModel.$setValidity('masterPassword', valid);
return value;
});
}
};
});