isImporting || $dataHandler->bypassAccessCheckForRecords) { return; } $request = $this->sudoModeInterceptor->currentRequest; if ($request === null) { // Not in a backend request where the sudoMode interceptor middleware was active return; } $schema = $this->tcaSchemaFactory->get($tableName); $subjects = []; $id = (string)$id; foreach ($schema->getFields() as $columnName => $fieldInformation) { $authenticationContextConfig = $fieldInformation->getConfiguration()['authenticationContext'] ?? null; if ($authenticationContextConfig === null) { continue; } $subject = $this->factory->buildTableAccessSubject( $tableName, $columnName, str_starts_with($id, 'NEW') ? 'NEW' : $id, $authenticationContextConfig ); $grants = $this->storage->findGrantsBySubject($subject); $hasGrant = $grants !== []; $subjects[$columnName] = [ 'subject' => $subject, 'grants' => $grants, 'hasGrant' => $hasGrant, ]; } $requiredSubjects = []; foreach ($fieldArray as $identifier => $value) { $subjectInfo = $subjects[$identifier] ?? null; if ($subjectInfo === null) { continue; } if ($subjectInfo['hasGrant']) { continue; } $subject = $subjectInfo['subject']; $requiredSubjects[$subject->getIdentity()] = $subject; } if ($requiredSubjects !== []) { $claim = $this->factory->buildClaimForSubjectRequest($request, self::class, ...array_values($requiredSubjects)); $event = new SudoModeRequiredEvent($claim); $this->eventDispatcher->dispatch($event); if ($event->isVerificationRequired()) { throw (new VerificationRequiredException( 'Authentication Context Confirmation Required', 1743597646 ))->withClaim($claim); } } $this->consumeNonRepeatableGrants($subjects); } private function consumeNonRepeatableGrants(array $subjects): void { // Consume (remove from storage) non-repeatable grants. // Non-repeatable grants have been marked with `once` in the subject configration. foreach ($subjects as $columnName => $subjectInfo) { if ($subjectInfo['subject']->isOnce()) { foreach ($subjectInfo['grants'] as $grant) { $this->storage->removeGrant($grant); } } } } }