I just wanted to say if the user is not active, don't allow to login. I have made the controller as below, I am not sure what I am miising or what else I have to do here to make this work!
namespace App\Http\Controllers\Auth; use Illuminate\Auth\Authenticatable; use Illuminate\Foundation\Auth\AuthenticatesUsers; use App\User; use Validator; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ThrottlesLogins; use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; class AuthController extends Controller{ use AuthenticatesAndRegistersUsers, ThrottlesLogins; protected $redirectTo = '/home'; public function __construct() { $this->middleware($this->guestMiddleware(), ['except' => 'logout']); } protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:6|confirmed', ]); } protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); } public function authenticate() { if (Auth::attempt(['email' => $email, 'password' => $password, 'active' => 1])) { // Authentication passed... return redirect()->intended('dashboard'); } } }
My thinking was authenticate() method should do the trick!
Any suggestions?
Best Answer
The below code worked for my case:
for Laravel 5.3 need to add following code to LoginController