Skip to content

Commit

Permalink
LdapResourceForm: Remove hostname validator
Browse files Browse the repository at this point in the history
It's now done automatically by the connection itself.

refs #3639
  • Loading branch information
nilmerg committed Apr 23, 2019
1 parent 1d341f9 commit 1a030d3
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions application/forms/Config/Resource/LdapResourceForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,7 @@ public function createElements(array $formData)
'The hostname or address of the LDAP server to use for authentication.'
. ' You can also provide multiple hosts separated by a space'
),
'value' => 'localhost',
'validators' => array(
array(
'Callback',
false,
array(
'callback' => function ($v) {
$withoutScheme = $withScheme = false;
foreach (explode(' ', $v) as $uri) {
if (preg_match('~^(?<!://)[^:]+:\d+$~', $uri)) {
return false;
}

$url = Url::fromPath($uri);
if ($url->getScheme()) {
$withScheme = true;
} else {
$withoutScheme = true;
}
}

return $withScheme ^ $withoutScheme;
},
'messages' => array(
'callbackValue' => $this->translate(
'A protocol scheme such as ldap:// or ldaps:// is mandatory for URIs with a given'
. ' port and for all other URIs as well once a scheme is given for a single one.'
)
)
)
)
)
'value' => 'localhost'
)
);
$this->addElement(
Expand Down

0 comments on commit 1a030d3

Please sign in to comment.