@@ -35,6 +35,29 @@ if ($mode === 'scheduled-cycle') {
|
||||
if (auth()->check() || request()->hasSession()) {
|
||||
throw new RuntimeException('Scheduled proof must run without an authenticated session.');
|
||||
}
|
||||
$scope = app(RequisitionExpiryRun::class);
|
||||
$denied = 0;
|
||||
foreach (['foreign_origin', 'budget_create', 'submit'] as $action) {
|
||||
try {
|
||||
$scope->execute($input['request'], function () use ($input, $action) {
|
||||
$actor = User::query()->findOrFail($input['owner']);
|
||||
if ($action === 'foreign_origin') {
|
||||
app(CommonBudget::class)->for($actor, [$input['request'] + 999999 => 1]);
|
||||
} elseif ($action === 'budget_create') {
|
||||
app(CommonBudget::class)->for($actor, [$input['request'] => 1])->create([]);
|
||||
} else {
|
||||
$request = Requisition::query()->findOrFail($input['request']);
|
||||
app(RequisitionWorkflow::class)->submit($actor, $request, (string) Str::uuid(), $request->process_version);
|
||||
}
|
||||
});
|
||||
throw new RuntimeException('Scheduled scope unexpectedly allowed '.$action);
|
||||
} catch (HttpExceptionInterface $error) {
|
||||
if ($error->getStatusCode() !== 403 || $scope->tenantId() !== null) {
|
||||
throw $error;
|
||||
}
|
||||
$denied++;
|
||||
}
|
||||
}
|
||||
if (Artisan::call('sgc:approval-deadlines-tick') !== 0) {
|
||||
throw new RuntimeException('Scheduled deadline tick failed: '.Artisan::output());
|
||||
}
|
||||
@@ -53,7 +76,7 @@ if ($mode === 'scheduled-cycle') {
|
||||
throw new RuntimeException('Scheduled audit must distinguish automatic execution from an interactive act.');
|
||||
}
|
||||
echo json_encode(['scheduled_expiry_without_session' => true, 'scheduled_scope_closed' => true, 'scheduled_repeat_without_effects' => true,
|
||||
'scheduled_audit_explicit' => true], JSON_THROW_ON_ERROR);
|
||||
'scheduled_audit_explicit' => true, 'scheduled_unrelated_operations_denied' => $denied], JSON_THROW_ON_ERROR);
|
||||
exit;
|
||||
}
|
||||
if ($mode === 'legacy-cycles') {
|
||||
|
||||
Reference in New Issue
Block a user