'Laravel 9: change table and fields for authentication and login

I have changed the table and the Laravel Breeze fields for authentication to some custom ones. It looks fine but in AuthenticatedSessionController.php while I get Auth::Check() == true when it executes return redirect()->intended(RouteServiceProvider::HOME); I get redirected to login page without any error message.

AuthenticatedSessionController.php

public function store(LoginRequest $request)
{
    $request->authenticate();

    $request->session()->regenerate();
    //Auth::Check() == true here I get true.

    return redirect()->intended(RouteServiceProvider::HOME);
}

I have only modified $user->getAuthPassword to return the new field for password and the protected $table variable (and fillables) in user model to show the new table.



Solution 1:[1]

Did you specify the protected $primaryKey if your custom table primary key is not 'id'. In my case, it redirected me to dashboard when I specify the $primaryKey.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Henley YM