Skip to content

Commit

Permalink
Added LDAPRecord
Browse files Browse the repository at this point in the history
Fix for authentication page  not working when no "District" defined
Improved speed of setup page when not fully configured
Fix for missing DB columns on Authentication settings page
Fix for slider text being hidden by items below it
Set Core debug mode to false
  • Loading branch information
jacobsen9026 committed Jun 9, 2020
1 parent d83435c commit 6e72d4f
Show file tree
Hide file tree
Showing 14 changed files with 374 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
1 change: 1 addition & 0 deletions .idea/School Accounts Manager.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions app/api/ad/ADConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Adldap\Adldap\Auth\PasswordRequiredException;
use Adldap\Adldap\Auth\UsernameRequiredException;
use Adldap\AdldapException;
use Adldap\Connections\Provider;
use Adldap\Connections\ProviderInterface;
use App\Models\Database\DistrictDatabase;
Expand Down Expand Up @@ -75,17 +76,20 @@ public function __construct(array $configuration = [])
}
}


$this->addProvider($configuration);
try {
$this->addProvider($configuration);

set_error_handler([$this, 'handleError']);

if ($configuration["username"] !== '' && $configuration["password"] !== '') {
if ($configuration["username"] !== '' && $configuration["password"] !== '' && $configuration["base_dn"] !== '') {
$this->connection = $this->connect();
} else {
throw new AppException("Missing username or password");
}
new AppErrorHandler();
} catch (AdldapException $exception) {
$this->ldapLogger->warning($exception);

} catch (Exception $exception) {

self::$lastError = $exception->getMessage();
Expand Down Expand Up @@ -116,16 +120,20 @@ public static function isConnected(): bool
* Now check if connection is legit
*/
if (self::$instance->connection instanceof Provider === false) {
self::$logger->info("AD not connected");
return false;
}
/**
* Now check if the connection is connected
*/
self::$logger->debug(self::$instance->connection->getConnection()->getLastError());
if (!self::$instance->connection->getConnection()->getLastError()) {
self::$logger->info("AD not connected");

return false;
}

self::$logger->info("AD connected");

return true;
}
Expand Down
6 changes: 2 additions & 4 deletions app/app/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
use System\App\Error\AppErrorHandler;
use System\App\UserLogger;
use System\App\ControllerFactory;
use System\Core;
use System\Request;
use System\App\Router;
use App\Models\User\User;
Expand Down Expand Up @@ -151,10 +152,7 @@ private function setErrorMode(): void
public function inDebugMode(): bool
{

if (AppDatabase::getDebugMode()) {
return true;
}
return false;
return Core::inDebugMode();

}

Expand Down
6 changes: 3 additions & 3 deletions app/views/layouts/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@

<a class="dropdown-item" href="/settings/application">Settings</a>
<a class="dropdown-item" href="/settings/district/edit">Setup</a>
<a class="dropdown-item" href="#" data-toggle="modal"
data-target="#aboutAppModal">About</a>


</div>
Expand All @@ -130,7 +128,9 @@
<div class="dropdown-header"><strong> <?php echo $this->user->username; ?></strong></div>

<a class="dropdown-item" href="/settings/profile">Profile</a>

<a class="dropdown-item" href="#" data-toggle="modal"
data-target="#aboutAppModal">About</a>
<a class="dropdown-item" href="https://jacobsen9026.github.io/AD-Accounts-Manager/">Help</a>
<a class="dropdown-item" href="/logout">Logout</a>
</div>
</li>
Expand Down
5 changes: 1 addition & 4 deletions app/views/settings/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
$forceHTTPS->addOption("False", '0', !AppDatabase::getForceHTTPS());
$forceHTTPS->addOption("True", '1', AppDatabase::getForceHTTPS());

$debugMode = new FormSlider("Debug Mode", "Caution: Enabling debug mode is a security risk and should only be used on development systems.", "debugMode", AppDatabase::getDebugMode());
$debugMode->addOption("False", '0', !AppDatabase::getDebugMode());
$debugMode->addOption("True", '1', AppDatabase::getDebugMode());

$homepageMessage = new System\App\Forms\FormTextArea();
$homepageMessage->setLabel("Homepage Message")
->setSubLabel("Accepts HTML and inline style")
Expand All @@ -64,7 +62,6 @@
->addElementToNewRow($homepageMessage)
->addElementToNewRow($webFQDN)
->addElementToNewRow($forceHTTPS)
->addElementToCurrentRow($debugMode)
->addElementToNewRow($webHelpDesk)
->addElementToNewRow($submitButton);
echo $form->print();
Expand Down
11 changes: 5 additions & 6 deletions app/views/settings/authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$auth = new AuthDatabase();

if ($auth->getLDAPEnabled()) {
$adTestResult = ADConnection::isConnected();
$ldapConnected = ADConnection::isConnected();
}


Expand All @@ -44,17 +44,16 @@
$adminPassword->isPassword();


$ldapConnected = false;
if (ADConnection::isConnected()) {
$ldapConnected = true;
}

$isLDAPEnabled = $auth->getLDAPEnabled();
$ldapEnabled = new System\App\Forms\FormSlider("AD Logon Enabled", "Allow logon with Active Directory accounts", "ldapEnabled", $isLDAPEnabled);


$ldapEnabled->addOption("False", 0, !$isLDAPEnabled)
->addOption("True", 1, $isLDAPEnabled);
if (!$ldapConnected) {
$ldapEnabled->disable();
}


$button = new FormFloatingButton('<i class="h3 mb-0 fas fa-check"></i>');
$button->setId('floatingSaveButton')
Expand Down
6 changes: 3 additions & 3 deletions app/views/settings/district/create.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="container-fluid bg-white shadow p-3 mt-0 col-sm-10 col-md-9 col-lg-7 col-xl-5">
<h3 class="pt-3">Create New District</h3>
<h3 class="pt-3">Create New Domain</h3>
<?php

use System\App\Forms\Form;

$form = new Form('/settings/district/create');
$name = new \System\App\Forms\FormText('District Name', '', 'name');
$createButton = new \System\App\Forms\FormButton('Create District');
$name = new \System\App\Forms\FormText('Domain Nick Name', '', 'name');
$createButton = new \System\App\Forms\FormButton('Create Domain');
$form->addElementToCurrentRow($name)
->addElementToNewRow($createButton);
echo $form->print();
Expand Down
3 changes: 0 additions & 3 deletions app/views/settings/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
$smtpPassword = new FormText("SMTP Password", 'SMTP Auth password',
'smtpPassword', $email->getSMTPPassword());

$useSMTPSSL = new FormRadio('Use SMTP over SSL', 'Sends emails securly', 'useSMTPSSL');
$useSMTPSSL->addOption('False', 0, !$email->getUseSMTPSSL());
$useSMTPSSL->addOption('True', 1, $email->getUseSMTPSSL());

$useEncryption = new FormSlider('Use Encryption', 'Sends emails securly', 'useEncryption');
$useEncryption->addOption('False', 0, !$email->getUseSMTPEncryption());
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"visualappeal/php-auto-update": "^0.12.3",
"ext-zip": "*",
"ext-json": "*",
"ext-pdo": "*"
"ext-pdo": "*",
"directorytree/ldaprecord": "^1.7"
}
}
Loading

0 comments on commit 6e72d4f

Please sign in to comment.