Skip to content

FOUR-14395: Database Error: Table not found: 'project_assets' doesn't exist #6382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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