简体   繁体   中英

Symfony 4 BadCredentialsException return 500

when I try : throw new BadCredentialsException('invalid token')

I obtain in prod or dev a 500 error page, not a 401/403

How I can do that ?

In my AuthTokenAuthenticator class as service to catch header with x-token

You should throw an exception that implements HttpExceptionInterface .

For example

throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM