Symfony:AuthenticateToken函数跳过引发的异常

时间:2019-04-30 12:15:53

标签: php symfony authentication exception

我有一个ApiKeyAuthenticator,其中我的功能是

public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
{ 
    $username = $userProvider->getUsernameForApiKey($apiKey);
    if (!$username) {
        dump("xxxxxx");
        throw new CustomUserMessageAuthenticationException(
            sprintf('API Key "%s" does not exist.', $apiKey)
        );
    }
}

因此,如果没有$user,则应引发异常(我使用转储对它进行了测试)。 但是我得到了这个例外:

enter image description here

真的很奇怪,当我在Symfony的Logs中查看时,我发现堆栈并没有停在我想要的CustomUserMessageAuthenticationException上,而继续前进到AuthenticationCredentialsNotFoundException

enter image description here

有人可以解释一下,这是怎么了?

0 个答案:

没有答案