Skip to content

Commit

Permalink
Merge pull request #6382 from ProcessMaker/bug/FOUR-14395
Browse files Browse the repository at this point in the history
FOUR-14395: Database Error: Table not found: 'project_assets' doesn't exist
  • Loading branch information
ryancooley committed Mar 14, 2024
2 parents debf7ed + a97b7d1 commit 0b6ace9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ProcessMaker/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,37 @@ public function boot()
if ($user->is_administrator) {
return true;
}

// Let other policies handle the request.
return null;
});

try {
$permissions = Permission::select('name')->get();
// Define the Gate permissions
$permissions->each(function ($permission) {
Gate::define($permission->name, function (User $user, ...$params) use ($permission) {
$authorized = false;

// Check if the user has the permission
if ($user->hasPermission($permission->name)) {
return true;
}

// If the user has no projects, return false.
$projects = $this->getProjectsForUser($user->id);
if (empty($projects)) {
return false;
}

// Check if the user has 'create-projects' permission and the request is from specific endpoints
// Users that ONLY have 'create-projects' permission are allowed to access specific endpoints
$isAllowedEndpoint = $this->checkAllowedEndpoints($projects, request()->path());

if ($user->hasPermission('create-projects') && $isAllowedEndpoint) {
return $this->isProjectAsset($permission, $params);
$authorized = $this->isProjectAsset($permission, $params);
}

return false;
return $authorized;
});
});
} catch (\Exception $e) {
Expand Down

0 comments on commit 0b6ace9

Please sign in to comment.