Yes, it is safe to override the methods in the LoginController that are provided by the AuthenticatesUsers trait. In fact, that is the recommended way to add custom functionality to the login and logout processes.
To do this, simply copy the login() and logout() methods from the AuthenticatesUsers trait into your LoginController, and then modify them as needed to add your custom functionality. For example:
use AuthenticatesUsers;
class LoginController extends Controller
{
use AuthenticatesUsers;
public function login(Request $request)
{
// Add custom functionality here
return $this->attemptLogin($request);
}
public function logout(Request $request)
{
// Add custom functionality here
$this->guard()->logout();
$request->session()->invalidate();
return redirect('/');
}
}
Note that you should still include the use AuthenticatesUsers; statement at the top of your LoginController to ensure that the trait's methods are available to your controller.