I'm using Laravel 5.0 built-in authentication controllers. However, I'd like to add some actions during login besides authenticating, for example updating another table. I can't seem to find where I should write such code, though.
For registration I added what I wanted in the file "Registrar.php" under the folder "Services". How can I do that for Login?
Thanks in advance.
You can put following function in AuthController.php
to override default function from AuthenticatesAndRegistersUsers
trait. And you can change it as per your need.
/**
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postLogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email', 'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if ($this->auth->attempt($credentials, $request->has('remember')))
{
return redirect()->intended($this->redirectPath());
}
return redirect($this->loginPath())
->withInput($request->only('email', 'remember'))
->withErrors([
'email' => $this->getFailedLoginMessage(),
]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With