mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
removing hard chkpass directive and some other hard-coded configs
This commit is contained in:
parent
51855f1b82
commit
c7a86a3c6a
@ -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.
|
||||
*
|
||||
|
||||
@ -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 += "<div class='error' id='" + this.form.name + "-" + fld + "-url-error' ng-show='" + this.form.name + "_form." + fld +
|
||||
`.$error.awvalidurl'>${error_message}</div>`;
|
||||
}
|
||||
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 += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
||||
`.$error.password_length">${error_message}</div>`;
|
||||
}
|
||||
if ($AnsibleConfig.password_hasLowercase) {
|
||||
error_message = i18n._("Your password must contain a lowercase letter.");
|
||||
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
||||
`.$error.hasLowercase">${error_message}</div>`;
|
||||
}
|
||||
if ($AnsibleConfig.password_hasUppercase) {
|
||||
error_message = i18n._("Your password must contain an uppercase letter.");
|
||||
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
||||
`.$error.hasUppercase">${error_message}</div>`;
|
||||
}
|
||||
if ($AnsibleConfig.password_hasNumber) {
|
||||
error_message = i18n._("Your password must contain a number.");
|
||||
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
||||
`.$error.hasNumber">${error_message}</div>`;
|
||||
}
|
||||
if ($AnsibleConfig.password_hasSymbol) {
|
||||
error_message = i18n.sprintf(i18n._("Your password must contain one of the following characters: %s"), "`~!@#$%^&*()_-+=|}\]{\[;:\"\'?\/>.<,");
|
||||
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
||||
`.$error.hasSymbol">${error_message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
html += "<div class='error api-error' id='" + this.form.name + "-" + fld + "-api-error' ng-bind='" + fld + "_api_error'>\n</div>\n";
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user