I am currently using this method to provide a flash message to a user after a user logged in. This is using the default auth functionality of laravel(5.1)
.
Somebody suggested my to use this method in my AuthController
to override the default one.
public function authenticated(Request $request, User $user ) {
// Succes flash message
alert()->success('Succesvol ingelogd', 'Welkom');
return redirect()->intended( $this->redirectPath() );
}
The only problem is that I can not exactly figure out where this method comes from. Once a user logs in, the user will post his data to the postLogin method on the AuthenticatesUsers trait. If the auth attempt is successful this method calls the handleUserWasAuthenticated.
This method calls the the authenticated method like so:
protected function handleUserWasAuthenticated(Request $request, $throttles)
{
if ($throttles) {
$this->clearLoginAttempts($request);
}
if (method_exists($this, 'authenticated')) {
return $this->authenticated($request, Auth::user());
}
return redirect()->intended($this->redirectPath());
}
I can not figure out where the authenticated()
method is coming from though. Can somebody help me with figuring this out. I would like to understand more about this code so I don't have to constantly ask others for help with it.