We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ba39a48 commit ac5d861Copy full SHA for ac5d861
security/login_link.rst
@@ -671,9 +671,14 @@ First create the ``AuthenticationSuccessHandler``::
671
672
class AuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
673
{
674
- public function onAuthenticationSuccess(Request $request, TokenInterface $token)
+ public function onAuthenticationSuccess(Request $request, TokenInterface $token): JsonResponse
675
676
- // ...
+ // Example use case: Create API token for Guard Authentication.
677
+ $user = $token->getUser(); // Returns string|\Stringable|UserInterface - depends on your implementation.
678
+
679
+ $userApiToken = $user->getApiToken();
680
681
+ return new JsonResponse(['apiToken' => 'userApiToken']);
682
}
683
684
0 commit comments