Add checking for localhost in hostname fields.
This commit is contained in:
parent
cc453e7d10
commit
3a3945779d
3 changed files with 25 additions and 6 deletions
|
@ -10,6 +10,9 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
'isActive': '=isActive'
|
||||
},
|
||||
controller: function($rootScope, $scope, $element, $timeout, ApiService) {
|
||||
$scope.HOSTNAME_REGEX = '^[a-zA-Z-0-9\.]+(:[0-9]+)?$';
|
||||
$scope.GITHUB_REGEX = '^https?://([a-zA-Z0-9]+\.?\/?)+$';
|
||||
|
||||
$scope.SERVICES = [
|
||||
{'id': 'redis', 'title': 'Redis'},
|
||||
|
||||
|
@ -69,6 +72,14 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
]
|
||||
};
|
||||
|
||||
$scope.validateHostname = function(hostname) {
|
||||
if (hostname.indexOf('127.0.0.1') == 0 || hostname.indexOf('localhost') == 0) {
|
||||
return 'Please specify a non-localhost hostname. "localhost" will refer to the container, not your machine.'
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
$scope.config = null;
|
||||
$scope.mapped = {
|
||||
'$hasChanges': false
|
||||
|
@ -719,7 +730,8 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
'binding': '=binding',
|
||||
'placeholder': '@placeholder',
|
||||
'pattern': '@pattern',
|
||||
'defaultValue': '@defaultValue'
|
||||
'defaultValue': '@defaultValue',
|
||||
'validator': '&validator'
|
||||
},
|
||||
controller: function($scope, $element) {
|
||||
$scope.getRegexp = function(pattern) {
|
||||
|
@ -733,6 +745,8 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
if (!binding && $scope.defaultValue) {
|
||||
$scope.binding = $scope.defaultValue;
|
||||
}
|
||||
|
||||
$scope.errorMessage = $scope.validator({'value': binding || ''});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue