Skip to content
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

Return json on error for a json request #3285

Merged
merged 2 commits into from May 30, 2018
Merged

Return json on error for a json request #3285

merged 2 commits into from May 30, 2018

Conversation

@nanaya
Copy link
Collaborator

@nanaya nanaya commented May 30, 2018

ajax only covers requests with X-Requested-With=XMLHttpRequest.
And change expectsJson to wantsJson. The former also includes ajax requests.

ajax only covers requests with `X-Requested-With=XMLHttpRequest`.
And change expectsJson to wantsJson. The former also includes ajax requests.
@notbakaneko
Copy link
Collaborator

@notbakaneko notbakaneko commented May 30, 2018

Actually, why doesn't the html version of unauthenticated return 401 as well?

@@ -120,7 +120,7 @@ public function render($request, Exception $e)

protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
if ($request->wantsJson()) {
@nanaya
Copy link
Collaborator Author

@nanaya nanaya commented May 30, 2018

I vaguely remember browsers showing native auth dialog if returning 401.

@peppy peppy added this to the May 2018 milestone May 30, 2018
@peppy peppy merged commit afdd808 into ppy:master May 30, 2018
2 checks passed
2 checks passed
continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@nanaya nanaya deleted the nanaya:json_return branch Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants