commit compras1 3011
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-30 09:33:36 +02:00
parent 96b30368bc
commit 47649bd46c
163 changed files with 9419 additions and 145 deletions
+21
View File
@@ -2,6 +2,7 @@
namespace App\Services;
use App\Models\PrivateAuditExport;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
@@ -31,6 +32,26 @@ final class PrivateAuditAccess
&& Schema::hasTable('private_audit_exports');
}
/** Exact historical archives approved for the installation's context transition.
* @return list<int>
*/
public function legacyExportIds(User $actor, string $context): array
{
if ($context !== 'procurement.internal' || auth()->id() !== $actor->id || $actor->tenant_id === null) {
return [];
}
$pins = config('private-audit.legacy_export_transitions.'.$actor->tenant_id, []);
if (! is_array($pins) || $pins === []) {
return [];
}
return array_values(PrivateAuditExport::query()->where('tenant_id', $actor->tenant_id)->where('created_by', $actor->id)->where('work_context', 'legacy')
->whereIn('id', array_keys($pins))->get(['id', 'sha256'])
->filter(fn (PrivateAuditExport $export) => is_string($pins[$export->id] ?? null)
&& preg_match('/^[a-f0-9]{64}$/D', $pins[$export->id]) === 1 && hash_equals($pins[$export->id], $export->sha256))
->map(fn (PrivateAuditExport $export) => (int) $export->id)->all());
}
/** @return array{actor:User,context:string,granted:list<string>} */
public function current(User $candidate): array
{