feat: implement initial project, document, and resource management modules with routing, controllers, and UI components
This commit is contained in:
@@ -21,6 +21,14 @@ class UserController extends Controller
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$query = User::with(['roles', 'employeeProfile', 'customerProfile', 'contractor']);
|
||||
// Super Admin and platform admin roles are never restricted by a legacy
|
||||
// contractor link on their account.
|
||||
$authUser = $request->user();
|
||||
$isPlatformAdmin = $authUser && $authUser->hasAnyRole(['Super Admin', 'admin']);
|
||||
|
||||
if ($authUser && ! $isPlatformAdmin && ! is_null($authUser->contractor_id)) {
|
||||
$query->where('contractor_id', $authUser->contractor_id);
|
||||
}
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$search = $request->search;
|
||||
@@ -448,6 +456,10 @@ class UserController extends Controller
|
||||
{
|
||||
$authUser = auth()->user();
|
||||
|
||||
if ($authUser->hasAnyRole(['Super Admin', 'admin'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! is_null($authUser->contractor_id) && $user->contractor_id !== $authUser->contractor_id) {
|
||||
abort(redirect()->route('users.index')->with('error', 'You do not have permission to access this user.'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user