So, I am using Laravel 9x with Jetstream and Inertia/Vue
I am noticing using PGSQL and SQLite the login for email is case sensitive. What is the solution to fix this? I know I am not posting code because it doesnt seem necessary but if there is something you want to see let me know.
I have also heard this does NOT happen with MySQL but I have not tested it yet.
I can't speak to Jetstream specifically, but our app uses FormRequest
classes for the login, password reset, etc. forms.
In each FormRequest
, we use Laravel's prepareForValidation()
method to massage the incoming data.
protected function prepareForValidation($attributes) {
$attributes['email'] = strtolower(trim($attributes['email']));
return $attributes;
}
Additionally, in the User model, we have an Eloquent mutator on the email property to ensure updates to this field are normalized:
public function setEmailAttribute($value) {
$this->attributes['email'] = trim(strtolower($value));
}
(You could also handle this with an Eloquent observer on the saving
event.)
After changing your app to do this, you'd likely want to run a one-time update to your database to lowercase existing email values in the users table. Forgetting to do this would make it impossible for users with uppercase characters to log in.