Open eugenem opened 8 years ago
add a middleware which will check your field and then add this to middleware group or admin config
Would you mind to detail that? I'm not so good in middlewares...
you can generate middleware with artisan, and inside just check using your facade (in my case it's AdminAuth) if your user field is_active is false and return abort(403) or redirect, or whatever you want
This is what I've tried, and I'm getting redirect loop after trying to login with disabled user...
class AdminAuthenticate
{
public function handle($request, Closure $next)
{
if ( $request->path() != 'admin/login' && ( AdminAuth::guest() || !AdminAuth::user()->is_active ))
{
AdminAuth::logout();
if ($request->ajax())
{
return response('Unauthorized.', 401);
} else
{
return redirect()->guest(route('admin.login'));
}
}
return $next($request);
}
}
I've got custom Admin model (v3) that has is_active field. I can edit admins nicely using the admin forms. Question is: how do I add check for is_active = 1 to login process? I want to be able to disable some admins without deleting them...