Basic user management
This commit is contained in:
@@ -10,6 +10,11 @@ class AuthCheckProvider {
|
||||
|
||||
$user = auth()->user();
|
||||
$tenant = app('tenant');
|
||||
if ($tenant->slug === 'lv') {
|
||||
return $user->active;
|
||||
}
|
||||
|
||||
|
||||
return $user->active && $tenant->slug === $user->tenant;
|
||||
}
|
||||
|
||||
@@ -18,6 +23,10 @@ class AuthCheckProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
return auth()->user()->user_role;
|
||||
if (app('tenant')->slug === 'lv') {
|
||||
return auth()->user()->user_role_main;
|
||||
}
|
||||
|
||||
return auth()->user()->user_role_local_group;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
@@ -21,9 +22,10 @@ final class InertiaProvider
|
||||
|
||||
public function render() : Response {
|
||||
$this->props['navbar'] = $this->generateNavbar();
|
||||
$this->props['tenant'] = app('tenant')->local_group_name;
|
||||
$this->props['tenant'] = app('tenant');
|
||||
$this->props['user'] = $this->user;
|
||||
$this->props['currentPath'] = request()->path();
|
||||
$this->props['availableLocalGroups'] = Tenant::where(['is_active_local_group' => true])->get();
|
||||
|
||||
return Inertia::render(
|
||||
str_replace('/', '/Views/', $this->vueFile),
|
||||
|
||||
@@ -8,6 +8,8 @@ class TenantUserProvider extends EloquentUserProvider
|
||||
{
|
||||
public function retrieveByCredentials(array $credentials)
|
||||
{
|
||||
$credentials['active'] = true;
|
||||
|
||||
$query = $this->createModel()->newQuery();
|
||||
|
||||
foreach ($credentials as $key => $value) {
|
||||
@@ -16,8 +18,12 @@ class TenantUserProvider extends EloquentUserProvider
|
||||
}
|
||||
}
|
||||
|
||||
if (app('tenant')->slug === 'lv') {
|
||||
return $query->first();
|
||||
}
|
||||
|
||||
$query->where([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'local_group' => app('tenant')->slug,
|
||||
'active' => true
|
||||
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user