Skip to content

Instantly share code, notes, and snippets.

@meeDamian
Created March 15, 2014 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meeDamian/9574783 to your computer and use it in GitHub Desktop.
Save meeDamian/9574783 to your computer and use it in GitHub Desktop.
angular.module("app.directives", []).directive('pwdMatch', function() {
return {
link: function(scope, elm, attrs) {
var checker;
checker = function() {
return elm.val() === scope.$eval(attrs.pwdMatch);
};
return scope.$watch(checker, function(n) {
return console.log("passwords" + (!n ? " do not" : "") + " match");
});
}
};
}).directive("minStrength", function() {
return {
link: function(scope, elm, attrs) {
var checker, minStrength;
minStrength = attrs.minStrength;
checker = function() {
var result;
result = zxcvbn(elm.val());
attrs.$set("break-time", result.crack_time_display);
attrs.$set("strength", result.score);
return result.score > minStrength;
};
return scope.$watch(checker, function(n) {
return console.log("password strength " + (n ? "is ok" : "sucks"));
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment