diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 7a19223..3f0ae8f 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -2,11 +2,12 @@ namespace App\Http\Controllers\Auth; -use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; +use App\Http\Controllers\Controller; +use App\Providers\RouteServiceProvider; + class LoginController extends Controller { /* diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index ad53005..5af3d11 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -8,13 +8,23 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\File; +use LdapRecord\Models\ModelNotFoundException; use App\Ldap\Entry; use App\Classes\LDAP\Server; -use LdapRecord\Models\ModelNotFoundException; class HomeController extends Controller { + /** + * Debug Page + * + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View + */ + public function debug() + { + return view('debug'); + } + /** * Application home page */ diff --git a/app/Ldap/Entry.php b/app/Ldap/Entry.php index 7f57794..9b60322 100644 --- a/app/Ldap/Entry.php +++ b/app/Ldap/Entry.php @@ -5,8 +5,7 @@ namespace App\Ldap; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use LdapRecord\Models\Model; -use LdapRecord\Models\ModelNotFoundException; -use LdapRecord\Query\Model\Builder; +use LdapRecord\Query\ObjectNotFoundException; use App\Classes\LDAP\Attribute\Factory; @@ -19,16 +18,30 @@ class Entry extends Model */ public static $objectClasses = []; + /* OVERRIDES */ + + public function getAttributes(): array + { + $result = collect(); + foreach (parent::getAttributes() as $attribute => $value) { + $result->put($attribute,Factory::create($attribute,$value)); + } + + return $result->toArray(); + } + + /* STATIC METHODS */ + /** * Gets the root DN of the specified LDAPServer, or throws an exception if it * can't find it. * * @param null $connection * @return Collection - * @throws ModelNotFoundException + * @throws ObjectNotFoundException * @testedin GetBaseDNTest::testBaseDNExists(); */ - public function baseDN($connection = NULL): ?Collection + public static function baseDN($connection = NULL): ?Collection { $base = static::on($connection ?? (new static)->getConnectionName()) ->in(NULL) @@ -45,16 +58,21 @@ class Entry extends Model return $result; } - public function getAttributes(): array - { - $result = collect(); - foreach (parent::getAttributes() as $attribute => $value) { - $result->put($attribute,Factory::create($attribute,$value)); - } + /* ATTRIBUTES */ - return $result->toArray(); + /** + * Return a key to use for sorting + * + * @todo This should be the DN in reverse order + * @return string + */ + public function getSortKeyAttribute(): string + { + return $this->getDn(); } + /* METHODS */ + /** * Return an icon for a DN based on objectClass * @@ -126,7 +144,7 @@ class Entry extends Model * * @param null $connection * @return Entry|null - * @throws ModelNotFoundException + * @throws ObjectNotFoundException * @testedin TranslateOidTest::testRootDSE(); */ public function rootDSE($connection = NULL): ?Entry diff --git a/app/Ldap/User.php b/app/Ldap/User.php index 733535a..69b1729 100644 --- a/app/Ldap/User.php +++ b/app/Ldap/User.php @@ -17,4 +17,11 @@ class User extends Model public static $objectClasses = [ 'posixAccount', ]; -} + + /* METHODS */ + + public function getDn(): string + { + return $this->exists ? parent::getDn() : 'Anonymous'; + } +} \ No newline at end of file diff --git a/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php b/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php index 796bd3e..f545130 100644 --- a/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php +++ b/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php @@ -37,9 +37,16 @@
+ {{-- + --}} + @env(['local']) + + @endenv