Basic design created
This commit is contained in:
23
app/Providers/AuthCheckProvider.php
Normal file
23
app/Providers/AuthCheckProvider.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
class AuthCheckProvider {
|
||||
public function checkLoggedIn() : bool {
|
||||
if (!auth()->check()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = auth()->user();
|
||||
$tenant = app('tenant');
|
||||
return $user->active && $tenant->slug === $user->tenant;
|
||||
}
|
||||
|
||||
public function getUserRole() : ?string {
|
||||
if (!$this->checkLoggedIn()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return auth()->user()->user_role;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
@@ -10,17 +11,43 @@ final class InertiaProvider
|
||||
private string $vueFile;
|
||||
private array $props;
|
||||
|
||||
private ?User $user;
|
||||
|
||||
public function __construct(string $vueFile, array $props) {
|
||||
$this->user = auth()->user();
|
||||
$this->vueFile = $vueFile;
|
||||
$this->props = $props;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function render() : Response {
|
||||
$this->props['navbar'] = $this->generateNavbar();
|
||||
$this->props['tenant'] = app('tenant')->local_group_name;
|
||||
$this->props['user'] = $this->user;
|
||||
$this->props['currentPath'] = request()->path();
|
||||
|
||||
return Inertia::render(
|
||||
str_replace('/', '/Views/', $this->vueFile),
|
||||
$this->props
|
||||
);
|
||||
}
|
||||
|
||||
private function generateNavbar() : array {
|
||||
$navigation = [
|
||||
'personal' => [],
|
||||
'common' => [],
|
||||
'costunits' => [],
|
||||
'events' => [],
|
||||
];
|
||||
|
||||
$navigation['personal'][] = ['url' => '/', 'display' => 'Home'];
|
||||
if (null !== $this->user) {
|
||||
$navigation['personal'][] = ['url' => '/personal-data', 'display' => 'Meine Daten'];
|
||||
$navigation['personal'][] = ['url' => '/messages', 'display' => 'Meine Nachrichten'];
|
||||
}
|
||||
|
||||
$navigation['common'][] = ['url' => '/capture-invoice', 'display' => 'Neue Abrechnung'];
|
||||
$navigation['common'][] = ['url' => '/available-events', 'display' => 'Verfügbare Veranstaltungen'];
|
||||
|
||||
return $navigation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,11 @@ class TenantUserProvider extends EloquentUserProvider
|
||||
}
|
||||
}
|
||||
|
||||
$query->where('tenant', app('tenant')->slug);
|
||||
$query->where([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'active' => true
|
||||
|
||||
]);
|
||||
|
||||
return $query->first();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user