@@ -16,7 +16,7 @@ class PortalProfileAccess
|
||||
/** @return list<string> */
|
||||
public static function fingerprintFiles(): array
|
||||
{
|
||||
return [__FILE__, app_path('Services/OpportunityContacts.php'), resource_path('js/components/opportunity-contact-form.tsx'), app_path('Services/PortalInternalDesignation.php'), app_path('Models/User.php'), app_path('Models/Opportunity.php'), config_path('portal.php'), base_path('routes/web.php'),
|
||||
return [__FILE__, app_path('Services/OpportunityClassification.php'), app_path('Http/Controllers/OpportunityClassificationController.php'), resource_path('js/components/opportunity-classification.tsx'), app_path('Services/OpportunityContacts.php'), resource_path('js/components/opportunity-contact-form.tsx'), app_path('Services/PortalInternalDesignation.php'), app_path('Models/User.php'), app_path('Models/Opportunity.php'), config_path('portal.php'), base_path('routes/web.php'),
|
||||
app_path('Http/Middleware/HandleInertiaRequests.php'), app_path('Services/OpportunityManagement.php'),
|
||||
app_path('Services/OpportunityResources.php'), app_path('Services/OpportunityImageProcessor.php'), app_path('Services/VerifiedDocumentBinary.php'),
|
||||
app_path('Services/PortalProfileAdministration.php'), app_path('Services/PortalSuperusers.php'),
|
||||
@@ -39,7 +39,7 @@ class PortalProfileAccess
|
||||
resource_path('js/pages/dashboard.tsx'), resource_path('js/pages/PortalInvestidor.tsx'),
|
||||
resource_path('js/layouts/portal-navigation.tsx'), resource_path('js/components/interactive-investment-map.tsx'),
|
||||
resource_path('js/components/simulation-form.tsx'), resource_path('js/lib/simulation-form.ts'), app_path('Services/LegacyContent.php'),
|
||||
resource_path('js/components/ui/sidebar.tsx'), resource_path('js/components/simulation-financial-tools.tsx'), resource_path('js/components/simulation-cashflow-planner.tsx'), resource_path('js/pages/investor-path/show.tsx'), resource_path('views/app.blade.php'),
|
||||
resource_path('js/components/ui/sidebar.tsx'), resource_path('js/components/simulation-financial-tools.tsx'), resource_path('js/components/simulation-cashflow-planner.tsx'), resource_path('js/pages/investor-path/show.tsx'), resource_path('views/app.blade.php'), resource_path('views/profiles/creation-unavailable.blade.php'),
|
||||
resource_path('js/pages/management/opportunity-resources.tsx'),
|
||||
app_path('Services/PortalProfileInstallation.php'), app_path('Http/Controllers/PortalProfileInstallationController.php'), config_path('portal_profiles.php'), resource_path('js/pages/profiles/installation.tsx')];
|
||||
}
|
||||
@@ -162,6 +162,14 @@ class PortalProfileAccess
|
||||
return true;
|
||||
}
|
||||
|
||||
// Normal Promotor authority comes from its existing scope, not from the
|
||||
// Superutilizador membership. Other/extraneous actions retain elevation.
|
||||
if (in_array($action, ['view', 'edit'], true) && $recordId !== null) {
|
||||
$record = Opportunity::withTrashed()->find($recordId);
|
||||
if ($record && $record->owner_user_id !== null && $this->promoterRecordScope($actor, $record)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (! $this->mfa($actor)) {
|
||||
return false;
|
||||
}
|
||||
@@ -178,7 +186,8 @@ class PortalProfileAccess
|
||||
{
|
||||
$included = in_array($type, OpportunityCanonicalContract::BASE_CATEGORIES, true) || app(OpportunityModularProfiles::class)->enabled();
|
||||
|
||||
return $included && $this->available() && $this->scoped($actor, 'promoter', $organization, $type) && $this->operational($actor, 'create');
|
||||
// This is creation as an authorized Promotor, never an exceptional SU act.
|
||||
return $included && $this->available() && $this->scoped($actor, 'promoter', $organization, $type) && ! $this->has($actor, 'auditor');
|
||||
}
|
||||
|
||||
public function legacyWriteAllowed(User $actor): bool
|
||||
@@ -275,7 +284,30 @@ class PortalProfileAccess
|
||||
->where('scope->action', 'view')->whereNotNull('approved_by')->whereNull('consumed_at')->where('expires_at', '>', now())
|
||||
->get()->filter(fn ($row) => $this->operational($actor, 'view', json_decode($row->scope, true)['record_id'] ?? null))
|
||||
->map(fn ($row) => json_decode($row->scope, true)['record_id'])->all();
|
||||
$query->whereIn('id', $ids);
|
||||
$query->where(function ($eligible) use ($ids, $actor) {
|
||||
$eligible->whereIn('id', $ids);
|
||||
if ($this->has($actor, 'auditor')) {
|
||||
return;
|
||||
}
|
||||
foreach ($this->grants($actor, 'promoter') as $grant) {
|
||||
$internal = $grant->source === 'internal-portal-designation';
|
||||
if (($internal && app(PortalInternalDesignation::class)->organization($grant->organization_id) === null)
|
||||
|| (! $internal && ! $this->represents($actor, $grant->organization_id))) {
|
||||
continue;
|
||||
}
|
||||
$eligible->orWhere(function ($normal) use ($actor, $grant, $internal) {
|
||||
$normal->whereNotNull('owner_user_id')->whereIn('opportunity_category', json_decode($grant->opportunity_types, true));
|
||||
if ($internal) {
|
||||
$normal->where(fn ($q) => $q->where('owner_user_id', $actor->id)->orWhereJsonContains('workflow_context->contributors', $actor->id))
|
||||
->where('workflow_context->operator_organization_id', $grant->organization_id);
|
||||
} elseif ($grant->organization_id !== null) {
|
||||
$normal->where('organization_id', $grant->organization_id);
|
||||
} else {
|
||||
$normal->whereNull('organization_id')->where('owner_user_id', $actor->id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return $query->where(function ($scope) use ($actor) {
|
||||
|
||||
Reference in New Issue
Block a user