laravel / fortify

Backend controllers and scaffolding for Laravel authentication.
https://laravel.com/docs/fortify
MIT License
1.62k stars 294 forks source link

Cannot authenticate if the field "remember" is passed as false #546

Closed joaoribeiro-controlink closed 4 months ago

joaoribeiro-controlink commented 4 months ago

Fortify Version

1.21.3

Laravel Version

11.11.0

PHP Version

8.2.5

Database Driver & Version

MySQL 8

Description

Fortify does not make a successful authentication if the "remember" field is not passed as true.

Steps To Reproduce

Adding this to the FortifyServiceProvider on the boot method:

Fortify::authenticateUsing(function (Request $request) {
  if(Auth::attempt($request->only('username', 'password'), $request->filled('remember'))){
      // Regenerate the session to avoid session fixation
      $request->session()->regenerate();

      // Return the authenticated user instance
      return Auth::user();
  }

  return null;
});
driesvints commented 4 months ago

This should work. $remember is a boolean which when being false will just not remember the session.

driesvints commented 4 months ago

If you need help with this please try a support channel:

joaoribeiro-controlink commented 4 months ago

I found the problem, the User model cannot have the HasUuids Trait, if this is added to the model the login stop working