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

'ErrorException : Array to string conversion' if an array is posted to the login endpoint's email field #332

Closed
RJ2020DD opened this issue Dec 5, 2021 · 1 comment · Fixed by #333

Comments

@RJ2020DD
Copy link

RJ2020DD commented Dec 5, 2021

  • Fortify Version: 1.8.4
  • Laravel Version: 8.74.0
  • PHP Version: 8.0.11
  • Database Driver & Version: MySQL 8.0.26

Description:

When an array (or non scalar value) is posted to the login route for the email field, an 'ErrorException : Array to string conversion' is thrown by app/Providers/FortifyServiceProvider.php:40. This is due to the rate limiter key expecting a string value:

return Limit::perMinute(5)->by($request->email.$request->ip());

A genuine user shouldn't be posting an array but perhaps there should be a check to prevent the error? Also it would be good to still take advantage of the rate limiting as it's more than likely a spam/hack attempt. Therefore if

is_scalar($request->email);

was to return false, the key could be set to:

'nonscalar'.$request->ip()

Steps To Reproduce:

You can run this basic test to reproduce it;

public function test_posting_array_to_login_email_field()
{
    $this->withoutExceptionHandling();

    $this->post('/login', [
        'email' => [],
    ]);
}
@driesvints
Copy link
Member

Thanks, I've sent in a fix for this: #333

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

Successfully merging a pull request may close this issue.

2 participants