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

LogInController doesn't handle validation exceptions properly #3850

Open
dsevillamartin opened this issue Jul 1, 2023 · 0 comments
Open
Labels

Comments

@dsevillamartin
Copy link
Member

Current Behavior

Logging in is the only auth route that doesn't use the API.

  • Signing up is /register, which uses /api/users in the background
  • Forgot password is /api/forgot

By default, the LogInValidator doesn't have any rules. This is on purpose, so that it can be extended. However, if you have failing rules there, the ValidationExceptionHandler won't return JSON since this is not an API route. Instead, it'll return a 422 with the exception stack trace (in debug mode):

POST /login

Illuminate\Validation\ValidationException: The given data was invalid. in file ./vendor/flarum/core/src/Foundation/AbstractValidator.php on line 64
Stack trace:
  1. Illuminate\Validation\ValidationException->() ./vendor/flarum/core/src/Foundation/AbstractValidator.php:64
  2. Flarum\Foundation\AbstractValidator->assertValid() .vendor/flarum/core/src/Forum/Controller/LogInController.php:83

Steps to Reproduce

  1. Add a rule to LogInValidator (e.g. enable login recaptcha with fof/recaptcha)
  2. Fail the validation rules (e.g. make request to /login without g-recaptcha-response)
  3. View 422 with no JSON response

Expected Behavior

The route should return JSON on a validation exception

Screenshots

reCAPTCHA failure:

image
image

Authentication failure:

image

Environment

  • Flarum version: 1.8.1
  • Webserver: nginx

Output of php flarum info

No response

Possible Solution

No response

Additional Context

See FriendsOfFlarum/recaptcha#39 and https://discuss.flarum.org/d/18399-friendsofflarum-recaptcha/173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant