File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 1010use Symfony \Component \Security \Core \Authentication \Token \TokenInterface ;
1111use Symfony \Component \Security \Core \Exception \AuthenticationException ;
1212use Symfony \Component \Security \Core \Exception \CustomUserMessageAuthenticationException ;
13+ use Symfony \Component \Security \Core \Exception \TokenNotFoundException ;
1314use Symfony \Component \Security \Http \Authenticator \AbstractAuthenticator ;
1415use Symfony \Component \Security \Http \Authenticator \Passport \Badge \UserBadge ;
1516use Symfony \Component \Security \Http \Authenticator \Passport \Passport ;
@@ -38,9 +39,11 @@ public function authenticate(Request $request): Passport
3839 throw new CustomUserMessageAuthenticationException ('Authorization header cannot be empty. ' );
3940 }
4041
41- $ token = $ this ->introspectService ->itrospect (
42- substr ($ authorization , strlen ('Bearer ' ))
43- );
42+ try {
43+ $ token = $ this ->introspectService ->itrospect (substr ($ authorization , strlen ('Bearer ' )));
44+ } catch (\RuntimeException $ e ) {
45+ throw new TokenNotFoundException ('Invalid token. ' , 0 , $ e );
46+ }
4447
4548 $ event = $ this ->eventDispatcher ?->dispatch(new TokenVerifiedEvent ($ token ));
4649
You can’t perform that action at this time.
0 commit comments