Just put the code in the login controller, you just need to override the trait as needed.
Jan 27, 2020
6
Level 2
Running database query with user login request data
I want to run a database query with the user login form request data before logging the user in. I have been able to achieve this on my localhost by adding the query to AuthenticateUsers.php in my vendor folder but once I move to my cloud hosting service, the code to i added to my vendor folder in development is not included. I know it is not advisable to make changes to the files in the vendor folder. Please i need help to run database query right before user login (laravel 6)
Level 75
Try adding
public function login(Request $request)
{
////// HERE GET THE INFO FROM REQUEST AND DO YOUR QUERY/////////
//// LEAVE BELOW THIS ALONE //////////////////
//// BELOW MAY NOT EVEN BE NEEDED TO WORK TRY WITHOUT FIRST
$this->validateLogin($request);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if (method_exists($this, 'hasTooManyLoginAttempts') &&
$this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request);
}
Whatever you did in vendor will work here, a trait is to override with custom as needed.
Please or to participate in this conversation.