refactor: finish logic and definition separation (#6883)

Clean up rewrites to only have function definitions
Move authentication initialization into a function
This commit is contained in:
Tony Murray
2017-07-03 15:38:58 -05:00
committed by GitHub
parent 5020f47838
commit 20b08cf595
14 changed files with 935 additions and 943 deletions

View File

@@ -2,13 +2,18 @@
use LibreNMS\Exceptions\AuthenticationException;
$ldap_connection = @ldap_connect($config['auth_ldap_server'], $config['auth_ldap_port']);
function init_auth()
{
global $config, $ldap_connection;
if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require')) {
$tls = ldap_start_tls($ldap_connection);
if ($config['auth_ldap_starttls'] == 'require' && $tls === false) {
echo '<h2>Fatal error: LDAP TLS required but not successfully negotiated:'.ldap_error($ldap_connection).'</h2>';
exit;
$ldap_connection = @ldap_connect($config['auth_ldap_server'], $config['auth_ldap_port']);
if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require')) {
$tls = ldap_start_tls($ldap_connection);
if ($config['auth_ldap_starttls'] == 'require' && $tls === false) {
echo '<h2>Fatal error: LDAP TLS required but not successfully negotiated:'.ldap_error($ldap_connection).'</h2>';
exit;
}
}
}