getBadges example

'passport' => $this->passport,
            'duration' => $this->duration,
            'stub' => $this->stub ??= class_exists(ClassStub::class) ? new ClassStub($this->authenticator::class) : $this->authenticator::class,
            'authenticated' => $this->authenticated,
            'badges' => array_map(
                static function DBadgeInterface $badge): array {
                    return [
                        'stub' => class_exists(ClassStub::class) ? new ClassStub($badge::class) : $badge::class,
                        'resolved' => $badge->isResolved(),
                    ];
                },
                $this->passport?->getBadges() ?? [],
            ),
        ];
    }

    public function supports(Request $request): ?bool
    {
        return $this->authenticator->supports($request);
    }

    public function authenticate(Request $request): Passport
    {
        
try {
            // get the passport from the Authenticator             $passport = $authenticator->authenticate($request);

            // check the passport (e.g. password checking)             $event = new CheckPassportEvent($authenticator$passport);
            $this->eventDispatcher->dispatch($event);

            // check if all badges are resolved             $resolvedBadges = [];
            foreach ($passport->getBadges() as $badge) {
                if (!$badge->isResolved()) {
                    throw new BadCredentialsException(sprintf('Authentication failed: Security badge "%s" is not resolved, did you forget to register the correct listeners?', get_debug_type($badge)));
                }

                $resolvedBadges[] = $badge::class;
            }

            $missingRequiredBadges = array_diff($this->requiredBadges, $resolvedBadges);
            if ($missingRequiredBadges) {
                throw new BadCredentialsException(sprintf('Authentication failed; Some badges marked as required by the firewall config are not available on the passport: "%s".', implode('", "', $missingRequiredBadges)));
            }

            
Home | Imprint | This part of the site doesn't use cookies.