From c7a86a3c6a0f5f0a91be96161ac35d230f5c3d35 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Tue, 8 Aug 2017 15:50:11 -0700 Subject: [PATCH] removing hard chkpass directive and some other hard-coded configs --- awx/ui/client/src/shared/directives.js | 94 ------------------- awx/ui/client/src/shared/form-generator.js | 46 --------- .../shared/load-config/load-config.factory.js | 38 +------- .../shared/parse/parse-type-change.factory.js | 25 ++++- awx/ui/client/src/users/users.form.js | 1 - 5 files changed, 25 insertions(+), 179 deletions(-) diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js index c244adbf23..e806f86ba5 100644 --- a/awx/ui/client/src/shared/directives.js +++ b/awx/ui/client/src/shared/directives.js @@ -65,64 +65,6 @@ angular.module('AWDirectives', ['RestServices', 'Utilities']) }; }) -// chkPass -// -// Enables use of js/shared/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; - if (elm.val()) { - if ($AnsibleConfig.password_length) { - validity = (ctrl.$modelValue.length >= $AnsibleConfig.password_length); - ctrl.$setValidity('password_length', validity); - } - if ($AnsibleConfig.password_hasLowercase) { - validity = (/[a-z]/.test(ctrl.$modelValue)); - ctrl.$setValidity('hasLowercase', validity); - } - if ($AnsibleConfig.password_hasUppercase) { - validity = (/[A-Z]/.test(ctrl.$modelValue)); - ctrl.$setValidity('hasUppercase', validity); - } - if ($AnsibleConfig.password_hasNumber) { - validity = (/[0-9]/.test(ctrl.$modelValue)); - ctrl.$setValidity('hasNumber', validity); - } - if ($AnsibleConfig.password_hasSymbol) { - validity = (/[\\#@$-/:-?{-~!"^_`\[\]]/.test(ctrl.$modelValue)); - ctrl.$setValidity('hasSymbol', validity); - } - } else { - validity = true; - if ($AnsibleConfig.password_length) { - ctrl.$setValidity('password_length', validity); - } - if ($AnsibleConfig.password_hasLowercase) { - ctrl.$setValidity('hasLowercase', validity); - } - if ($AnsibleConfig.password_hasUppercase) { - ctrl.$setValidity('hasUppercase', validity); - } - if ($AnsibleConfig.password_hasNumber) { - ctrl.$setValidity('hasNumber', validity); - } - if ($AnsibleConfig.password_hasSymbol) { - ctrl.$setValidity('hasSymbol', validity); - } - } - if (!scope.$$phase) { - scope.$digest(); - } - }); - } - }; -}]) - // imageUpload // // Accepts image and returns base64 information with basic validation @@ -1116,42 +1058,6 @@ function(ConfigurationUtils, i18n, $rootScope) { }; }]) -// -// awRefresh -// -// Creates a timer to call scope.refresh(iterator) ever N seconds, where -// N is a setting in config.js -// -.directive('awRefresh', ['$rootScope', function($rootScope) { - return { - link: function(scope) { - function msg() { - var num = '' + scope.refreshCnt; - while (num.length < 2) { - num = '0' + num; - } - return 'Refresh in ' + num + ' sec.'; - } - scope.refreshCnt = $AnsibleConfig.refresh_rate; - scope.refreshMsg = msg(); - if ($rootScope.timer) { - clearInterval($rootScope.timer); - } - $rootScope.timer = setInterval(function() { - scope.refreshCnt--; - if (scope.refreshCnt <= 0) { - scope.refresh(); - scope.refreshCnt = $AnsibleConfig.refresh_rate; - } - scope.refreshMsg = msg(); - if (!scope.$$phase) { - scope.$digest(); - } - }, 1000); - } - }; -}]) - /* * Make an element draggable. Used on inventory groups tree. * diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 2991a138a0..10b6ae0a62 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -433,23 +433,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat scope[form.name + '_form'][fld].$setPristine(); scope[form.name + '_form'][fld].$setValidity('apiError', true); } - if (f.chkPass && scope[form.name + '_form'][fld] && $AnsibleConfig) { - if ($AnsibleConfig.password_length) { - scope[form.name + '_form'][fld].$setValidity('password_length', true); - } - if ($AnsibleConfig.password_hasLowercase) { - scope[form.name + '_form'][fld].$setValidity('hasLowercase', true); - } - if ($AnsibleConfig.password_hasUppercase) { - scope[form.name + '_form'][fld].$setValidity('hasUppercase', true); - } - if ($AnsibleConfig.password_hasNumber) { - scope[form.name + '_form'][fld].$setValidity('hasNumber', true); - } - if ($AnsibleConfig.password_hasSymbol) { - scope[form.name + '_form'][fld].$setValidity('hasSymbol', true); - } - } if (f.awPassMatch && scope[form.name + '_form'][fld]) { scope[form.name + '_form'][fld].$setValidity('awpassmatch', true); } @@ -920,7 +903,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += (field.controlNGClass) ? "ng-class='" + field.controlNGClass + "' " : ""; html += "class='form-control Form-textInput"; html += "' "; - html += (field.chkPass) ? "chk-pass " : ""; html += (field.placeholder) ? this.attr(field, 'placeholder') : ""; html += (field.required) ? "required " : ""; @@ -966,34 +948,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += "
${error_message}
`; } - if (field.chkPass && $AnsibleConfig) { - // password strength - if ($AnsibleConfig.password_length) { - error_message = i18n.sprintf(i18n._("Your password must be %d characters long."), $AnsibleConfig.password_length); - html += "
${error_message}
`; - } - if ($AnsibleConfig.password_hasLowercase) { - error_message = i18n._("Your password must contain a lowercase letter."); - html += "
${error_message}
`; - } - if ($AnsibleConfig.password_hasUppercase) { - error_message = i18n._("Your password must contain an uppercase letter."); - html += "
${error_message}
`; - } - if ($AnsibleConfig.password_hasNumber) { - error_message = i18n._("Your password must contain a number."); - html += "
${error_message}
`; - } - if ($AnsibleConfig.password_hasSymbol) { - error_message = i18n.sprintf(i18n._("Your password must contain one of the following characters: %s"), "`~!@#$%^&*()_-+=|}\]{\[;:\"\'?\/>.<,"); - html += "
${error_message}
`; - } - } html += "
\n
\n"; diff --git a/awx/ui/client/src/shared/load-config/load-config.factory.js b/awx/ui/client/src/shared/load-config/load-config.factory.js index cc269725dd..ee8be4e754 100644 --- a/awx/ui/client/src/shared/load-config/load-config.factory.js +++ b/awx/ui/client/src/shared/load-config/load-config.factory.js @@ -2,42 +2,8 @@ export default function LoadConfig($log, $rootScope, $http, Store) { return function() { - // These ettings used to be found in config.js, hardcoded now. - var configSettings = { - //custom_logo: false, // load /var/lib/awx/public/static/assets/custom_console_logo.png as the login modal header. if false, will load the standard console logo - // custom_login_info: "example notice", // have a notice displayed in the login modal for users. note that, as a security measure, custom html is not supported and will be escaped. - "tooltip_delay": { - "show": 500, - "hide": 100 - }, - "password_length": 8, - "password_hasLowercase": true, - "password_hasUppercase": false, - "password_hasNumber": true, - "password_hasSymbol": false, - "variable_edit_modes": { - "yaml": { - "mode": "text/x-yaml", - "matchBrackets": true, - "autoCloseBrackets": true, - "styleActiveLine": true, - "lineNumbers": true, - "gutters": ["CodeMirror-lint-markers"], - "lint": true, - "scrollbarStyle": null - }, - "json": { - "mode": "application/json", - "styleActiveLine": true, - "matchBrackets": true, - "autoCloseBrackets": true, - "lineNumbers": true, - "gutters": ["CodeMirror-lint-markers"], - "lint": true, - "scrollbarStyle": null - } - }, - }; + + var configSettings = {}; var configInit = function() { // Auto-resolving what used to be found when attempting to load local_setting.json diff --git a/awx/ui/client/src/shared/parse/parse-type-change.factory.js b/awx/ui/client/src/shared/parse/parse-type-change.factory.js index 1556acad78..7c63eb64f3 100644 --- a/awx/ui/client/src/shared/parse/parse-type-change.factory.js +++ b/awx/ui/client/src/shared/parse/parse-type-change.factory.js @@ -26,9 +26,30 @@ export default function createField(onChange, onReady, fld) { //hide the textarea and show a fresh CodeMirror with the current mode (json or yaml) - + let variableEditModes = { + yaml: { + mode: 'text/x-yaml', + matchBrackets: true, + autoCloseBrackets: true, + styleActiveLine: true, + lineNumbers: true, + gutters: ['CodeMirror-lint-markers'], + lint: true, + scrollbarStyle: null + }, + json: { + mode: 'application/json', + styleActiveLine: true, + matchBrackets: true, + autoCloseBrackets: true, + lineNumbers: true, + gutters: ['CodeMirror-lint-markers'], + lint: true, + scrollbarStyle: null + } + }; scope[fld + 'codeMirror'] = AngularCodeMirror(readOnly); - scope[fld + 'codeMirror'].addModes(global.$AnsibleConfig.variable_edit_modes); + scope[fld + 'codeMirror'].addModes(variableEditModes); scope[fld + 'codeMirror'].showTextArea({ scope: scope, model: fld, diff --git a/awx/ui/client/src/users/users.form.js b/awx/ui/client/src/users/users.form.js index 9c4e3d760d..4f6de00050 100644 --- a/awx/ui/client/src/users/users.form.js +++ b/awx/ui/client/src/users/users.form.js @@ -73,7 +73,6 @@ export default ['i18n', function(i18n) { labelNGClass: "{'prepend-asterisk' : $state.matches('add')}", ngChange: "clearPWConfirm('password_confirm')", autocomplete: false, - chkPass: true, ngDisabled: '!(user_obj.summary_fields.user_capabilities.edit || canAdd)' }, password_confirm: {