I am starting a new project, which is updating an old website, there is a requirement to move the old user accounts and user data over to the new system, when a user logs into the new site for the first time.
Therefore while I want to use the default Authentication in a Laravel 12 Starter Kit, it needs to be a manual authentication so that if the default system fails to find a match, I can look the user up on the old database in realtime, and start a worker to move the users data over and create a new account. That is all fine, but I am struggling to understand how to call the new authenticate function.
I have followed the authentication page (Laravel Docs) for manually authenticating users, thats fine, but I am struggling to understand how to correctly call it from the rest of the starter package.
Within AppHttpControllersAuthAuthenticatedSessionController.php there is this function
public function store(LoginRequest $request): RedirectResponse
{
$request->authenticate();
$request->session()->regenerate();
return redirect()->intended(route('dashboard', absolute: false));
}
Which is called when the Log In button on the login screen is clicked, but I think I need to replace the $request->authenticate(); line with the pointer to my bespoke function to attempt to authenticate the user.
However, if do something like
#$request->authenticate();
$bespokeAuth = new LogInController();
$request = $bespokeAuth->authenticate($request);
while my code is executed, the results are not being returned back to the store function, hence error messages are not returned, and the system no longer moves to the next page on a successful login.
Can anyone tell me what I am missing, or doing wrong please?