Skip to content

(fix): JsonResponse is mandatory for response. #9611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Guikingone
Copy link
Contributor

Small typo about the return of the action, in the case of Lexik is used, the response is created by Lexik but by default, Symfony will throw an exception telling that a Response is required.

@javiereguiluz
Copy link
Member

This looks a bit strange to me ... let's ask @dunglas because he originally developed this JSON login. Thanks!

@xabbuh
Copy link
Member

xabbuh commented Apr 20, 2018

This shouldn't be necessary as requests to this route should be intercepted by the Security layer.

@Guikingone
Copy link
Contributor Author

@xabbuh Yep, I know, the Security Layer should intercept the request and return a dedicated response along with the credentials.

Using 4.0.8, it throws an error saying that a Response must be returned, I've open the issue in 3.3 in the case this error occurs also in the 3.3 branch (which I've not tested).

@Guikingone
Copy link
Contributor Author

Here's the code :

Code

And the response via insomnia:

insomnia

If I say return new JsonResponse();, the response is returned and the body is empty (logic usage).

@javiereguiluz
Copy link
Member

@Guikingone thanks for the details about this issue. However, I still think this is either a Symfony bug or a third-party code bug. It's not mandatory to return anything in this method intercepted by Symfony. This should work as expected. 😕

@javiereguiluz
Copy link
Member

I've moved this to a Symfony issue: symfony/symfony#27124 Let's see if the community can verify this as a code bug or not. Closing for now then. Thanks!

javiereguiluz added a commit that referenced this pull request Oct 10, 2018
This PR was squashed before being merged into the 3.4 branch (closes #10467).

Discussion
----------

Fix and improve JSON login docs

Since symfony/symfony#22494, it's mandatory to return a valid response in the controller to prevent a 500 error.

I've updated the docs accordingly, and added an example of what can be returned.

This PR is similar to #9611 (that was right, sorry I just noticed).

ping @vincentchalamon

Commits
-------

570dce3 Fix and improve JSON login docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants