Skip to content

Commit 94ef76e

Browse files
committed
feature #189 Add response message when not authenticated (VincentLanglet)
This PR was squashed before being merged into the 0.4-dev branch. Discussion ---------- Add response message when not authenticated Hi `@chalasr` This give something more friendly message in case of errors. From <img width="475" alt="image" src="https://github.com/thephpleague/oauth2-server-bundle/assets/9052536/a699fcf7-7345-49a1-8c05-0fc9281d82a5"> To ![image](https://github.com/thephpleague/oauth2-server-bundle/assets/9052536/937bddc1-140a-41d2-a4ec-0c8495aa8c3b) Can consider it Closes #188 Commits ------- d554d8d Add response message when not authenticated
2 parents 58d4b11 + d554d8d commit 94ef76e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Security/Authenticator/OAuth2Authenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function supports(Request $request): ?bool
6060

6161
public function start(Request $request, ?AuthenticationException $authException = null): Response
6262
{
63-
return new Response('', 401, ['WWW-Authenticate' => 'Bearer']);
63+
return new Response($authException?->getMessage() ?? 'Authentication required', 401, ['WWW-Authenticate' => 'Bearer']);
6464
}
6565

6666
/**

0 commit comments

Comments
 (0)