diff --git a/awx/ui/static/js/controllers/Users.js b/awx/ui/static/js/controllers/Users.js index 59300db90d..9c29967f78 100644 --- a/awx/ui/static/js/controllers/Users.js +++ b/awx/ui/static/js/controllers/Users.js @@ -157,10 +157,6 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, // If password value changes, make sure password_confirm must be re-entered scope[fld] = ''; scope[form.name + '_form'][fld].$setValidity('awpassmatch', false); - var score = chkPass(scope.password); - //if (score < 67) { - // good stuff happens... maybe this could be handled by a directive? - //} } } diff --git a/awx/ui/static/js/forms/Users.js b/awx/ui/static/js/forms/Users.js index 1a777e23c7..406c2181ec 100644 --- a/awx/ui/static/js/forms/Users.js +++ b/awx/ui/static/js/forms/Users.js @@ -66,7 +66,7 @@ angular.module('UserFormDefinition', []) editRequired: false, ngChange: "clearPWConfirm('password_confirm')", autocomplete: false, - pwMeter: true + chkPass: true }, password_confirm: { label: 'Confirm Password', diff --git a/awx/ui/static/lib/ansible/directives.js b/awx/ui/static/lib/ansible/directives.js index ecffc6d370..6ad1e07279 100644 --- a/awx/ui/static/lib/ansible/directives.js +++ b/awx/ui/static/lib/ansible/directives.js @@ -344,173 +344,32 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos $(elm).spinner(opts); } } + }]) + + // + // chkPass + // + // Enables use of lib/ansible/pwdmeter.js to check strengh of passwords. + // See controllers/Users.js for example. + // + .directive('chkPass', [ function() { + return { + require: 'ngModel', + link: function(scope, elm, attrs, ctrl) { + $(elm).keyup(function() { + var validity = true; + var score = chkPass(elm.val()); + if (elm.val()) { + validity = (score > 67) ? true : false; + } + ctrl.$setValidity('complexity', validity); + if (!scope.$$phase) { + scope.$digest(); + } + }); + } + } }]); - /* This has become more than a simple directive. All the logic for building the group selector tree - on the Hosts tab is here. Probably needs to move into the Hosts helper and/or Inventory helper. - */ - // .directive('awTree', ['Rest', 'ProcessErrors', 'Authorization', '$compile', '$rootScope', 'Wait', - // function(Rest, ProcessErrors, Authorization, $compile, $rootScope, Wait) { - // return { - // //require: 'ngModel', - - // replace: true, - - // transclude: true, - - // scope: { - // treeData: '=awTree' - // }, - - // replace: true, - - // template: - // "
' + parent.attr('data-description') + '
' : ''; - // } - // else { - // group = null; - // title = 'All Hosts' - // } - // // The following will trigger the host list to load. See Inventory.js controller. - // scope.$emit('refreshHost', group, title); - // } - - // function activate(e) { - // /* Set the clicked node as active */ - // var elm = angular.element(e.target); // - // var parent = angular.element(e.target.parentNode); //