@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user