Normalize email input for registration and login
Trim and lowercase email before storing or attempting login to avoid mismatches from case or surrounding whitespace. Updated RegisteredUserController@store to save 'email' => strtolower(trim($request->email)) and LoginRequest@authenticate to call Auth::attempt with the normalized email input.
This commit is contained in:
@@ -67,7 +67,7 @@ class RegisteredUserController extends Controller
|
|||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'name' => $request->name,
|
'name' => $request->name,
|
||||||
'email' => $request->email,
|
'email' => strtolower(trim($request->email)),
|
||||||
'password' => Hash::make($request->password),
|
'password' => Hash::make($request->password),
|
||||||
'rol_id' => $rol_id,
|
'rol_id' => $rol_id,
|
||||||
'parent_id' => $referralUser ? $referralUser->id : null,
|
'parent_id' => $referralUser ? $referralUser->id : null,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class LoginRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
$this->ensureIsNotRateLimited();
|
$this->ensureIsNotRateLimited();
|
||||||
|
|
||||||
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
if (! Auth::attempt(['email' => strtolower(trim($this->input('email'))), 'password' => $this->input('password')], $this->boolean('remember'))) {
|
||||||
RateLimiter::hit($this->throttleKey());
|
RateLimiter::hit($this->throttleKey());
|
||||||
|
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
|
|||||||
Reference in New Issue
Block a user