Skip to content

Commit

Permalink
Using JsonResponse + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Nov 22, 2015
1 parent 440fe6f commit 62dcae3
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions cookbook/security/guard-authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ This requires you to implement six methods::
namespace AppBundle\Security;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
Expand Down Expand Up @@ -217,7 +217,7 @@ This requires you to implement six methods::
// $this->translator->trans($exception->getMessageKey(), $exception->getMessageData())
);

return new Response(json_encode($data), 403);
return new JsonResponse($data, 403);
}

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

return new Response(json_encode($data), 401);
return new JsonResponse($data, 401);
}

public function supportsRememberMe()
Expand Down Expand Up @@ -571,7 +571,3 @@ Frequently Asked Questions
to actually authenticate the user. You can continue doing that (see previous
question) or use the ``User`` object from FOSUserBundle and create your own
authenticator(s) (just like in this article).

* :doc:`Creating a Login Form </cookbook/security/guard-login-form>`
* :doc:`Authenticating with an API Token </cookbook/security/guard-api-key>`
* :doc:`Using Multiple Authenticators (Login form *and* API Token) </cookbook/security/guard-multi>`

0 comments on commit 62dcae3

Please sign in to comment.