Skip to content

Commit 62dcae3

Browse files
committed
Using JsonResponse + cleanup
1 parent 440fe6f commit 62dcae3

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

cookbook/security/guard-authentication.rst

+3-7
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ This requires you to implement six methods::
149149
namespace AppBundle\Security;
150150

151151
use Symfony\Component\HttpFoundation\Request;
152-
use Symfony\Component\HttpFoundation\Response;
152+
use Symfony\Component\HttpFoundation\JsonResponse;
153153
use Symfony\Component\Security\Core\User\UserInterface;
154154
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
155155
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -217,7 +217,7 @@ This requires you to implement six methods::
217217
// $this->translator->trans($exception->getMessageKey(), $exception->getMessageData())
218218
);
219219

220-
return new Response(json_encode($data), 403);
220+
return new JsonResponse($data, 403);
221221
}
222222

223223
/**
@@ -230,7 +230,7 @@ This requires you to implement six methods::
230230
'message' => 'Authentication Required'
231231
);
232232

233-
return new Response(json_encode($data), 401);
233+
return new JsonResponse($data, 401);
234234
}
235235

236236
public function supportsRememberMe()
@@ -571,7 +571,3 @@ Frequently Asked Questions
571571
to actually authenticate the user. You can continue doing that (see previous
572572
question) or use the ``User`` object from FOSUserBundle and create your own
573573
authenticator(s) (just like in this article).
574-
575-
* :doc:`Creating a Login Form </cookbook/security/guard-login-form>`
576-
* :doc:`Authenticating with an API Token </cookbook/security/guard-api-key>`
577-
* :doc:`Using Multiple Authenticators (Login form *and* API Token) </cookbook/security/guard-multi>`

0 commit comments

Comments
 (0)