Search code examples
laravellaravel-5laravel-5.3

Call a function after login fails or success laravel 5.3


I want to call a custom function when the user success in login and another when fails but i can't find the solution, i use laravel 5.3 and make:auth method.

I have the LoginController but is almost emtpy.

The route for login post:

Route::post('login', ['as' => 'login.post', 'uses' => 'Auth\LoginController@login']);

I have a helper function called flash('The messaje') that sends an jquery alert on the view, i use in controllers and works fine, but i don't know where put this code to show an alert if the auth login fails and success.

Thanks!


Solution

  • As by default LoginController uses AuthenticatesUsers trait, all you need to is to write custom methods sendLoginResponse and sendFailedLoginResponse. You can of reuse trait methods and to add only custom mode you want to execute.