Reputation: 113
i want to edit auth and add Additional Conditions
for check user for active or ...
where can edit authcontroller code?
Upvotes: 0
Views: 1461
Reputation: 21
In Auth\AuthController.php, add this function ( I assume the column name for user status is "is_active" ):
public function authenticated($request, $user) {
if ($user->is_active != 'Y') {
Auth::logout();
return redirect('login')->withErrors([
$this->loginUsername() => 'Your '.$this->loginUsername().' is not active. Please contact Administrators'
]);
}else {
return redirect()->intended($this->redirectPath());
}
}
Upvotes: 1
Reputation: 5609
First you need a status
column in users
table to mark the user as active or inactive.
To check the user status during login you need to modify this file:
project_folder\vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php
You can change validateLogin()
method. I assume, for active user the status code is 1
and 0
for inactive user. Your code should look like this:
protected function validateLogin(Request $request)
{
$this->validate($request, [
$this->loginUsername() => 'required', 'password' => 'required', 'status' => 1,
]);
}
Upvotes: 1