1 <?php
2
3 namespace App\Http\Middleware;
4
5 use Closure;
6 use Illuminate\Contracts\Auth\Factory as AuthAdmin;
7 use Illuminate\Support\Facades\Auth;
8
9 class AuthenticateAdmin
10 {
11 12 13 14 15
16 protected $authAdmin;
17
18 19 20 21 22 23
24 public function __construct(AuthAdmin $authAdmin)
25 {
26 $this->authAdmin = $authAdmin;
27 }
28
29 30 31 32 33 34 35 36
37 public function handle($request, Closure $next, $guard = null)
38 {
39 $loggedInuser = Auth::user();
40 if ($loggedInuser->role!=1) {
41 return response('Unauthorized.', 401);
42 }
43 return $next($request);
44 }
45 }
46