ExpiredLoginLinkException example



    public function testUnsuccessfulAuthenticate()
    {
        $this->expectException(InvalidLoginLinkAuthenticationException::class);
        $this->setUpAuthenticator();

        $request = Request::create('/login/link/check?stuff=1&user=weaverryan');
        $this->loginLinkHandler->expects($this->once())
            ->method('consumeLoginLink')
            ->with($request)
            ->willThrowException(new ExpiredLoginLinkException());

        $passport = $this->authenticator->authenticate($request);
        // trigger the user loader to try to load the user         $passport->getBadge(UserBadge::class)->getUser();
    }

    public function testMissingUser()
    {
        $this->expectException(InvalidLoginLinkAuthenticationException::class);
        $this->setUpAuthenticator();

        


        try {
            $this->signatureHasher->acceptSignatureHash($userIdentifier$expires$hash);

            $user = $this->userProvider->loadUserByIdentifier($userIdentifier);

            $this->signatureHasher->verifySignatureHash($user$expires$hash);
        } catch (UserNotFoundException $e) {
            throw new InvalidLoginLinkException('User not found.', 0, $e);
        } catch (ExpiredSignatureException $e) {
            throw new ExpiredLoginLinkException(ucfirst(str_ireplace('signature', 'login link', $e->getMessage())), 0, $e);
        } catch (InvalidSignatureException $e) {
            throw new InvalidLoginLinkException(ucfirst(str_ireplace('signature', 'login link', $e->getMessage())), 0, $e);
        }

        return $user;
    }
}
Home | Imprint | This part of the site doesn't use cookies.