I have a custom login controller, and I need to check if user is active or not and if not respond with message like please active your account first.
Here is my controller
public function login( Request $request ) {
// validate the form data
$this->validate( $request, [
'email' => 'required|email',
'password' => 'required|min:6',
] );
// attempt to login the supplier in
if ( Auth::guard( 'supplier' )->attempt(
[
'email' => $request->email,
'password' => $request->password,
], $request->remember ) ) {
return redirect()->intended( route( 'supplier-dashboard' ) );
}
$errors = [ $this->username() => trans( 'auth.failed' ) ];
if ( $request->expectsJson() ) {
return response()->json( $errors, 422 );
}
return redirect()->back()
->withInput( $request->only( 'email', 'remember' ) )
->withErrors( $errors );
}
I can just add active => 1 to the if ( Auth::guard( 'supplier' )->attempt( but this will respond with wrong username or password
but I want it to respond with 'Active your account first'
any help appreciated.