I would not add the active field to the credentials - this is an authorization problem, not an authentication one.
For this, I would use middleware to check if login is active or inactive. In 5.3, the middleware will look like this:
<?php namespace App\Http\Middleware; use Closure; use Illuminate\Support\Facades\Auth; class RedirectIfInactive { public function handle($request, Closure $next) { if ( $user = Auth::guard('web')->user() ) { if ( ! $user->active ) return redirect(route('account_inactive')); } return $next($request); } }
Then this middleware should be registered inside Kernel.php :
protected $routeMiddleware = [ 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'inactive' => \App\Http\Middleware\RedirectIfInactive::class, ];
Finally, we protect all our routes:
Route::get('inactive', ['as' => 'account_inactive', function () { return view('inactive'); }]); Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => 'inactive'], function () { Route::get('/', ['as' => 'admin.home', 'uses' => ' AdminController@index ']); });
The advantage of this approach is that we can display a more relevant error message than the general "These credentials do not match our records" that people with bad data receive. Thus, the user will know that it is not their fault, they cannot enter the system.
In any case, with the approach in the accepted answer, make sure that you do the same when the user successfully resets his password, since it is also automatically registered.