1 | <?php |
||
2 | |||
3 | namespace Mongi\Mongicommerce\Http\Middleware; |
||
4 | |||
5 | use Closure; |
||
6 | use Illuminate\Support\Facades\Auth; |
||
7 | |||
8 | class AdminMiddleware |
||
9 | { |
||
10 | public function handle($request, Closure $next) |
||
11 | { |
||
12 | if (!Auth::check()) { |
||
13 | // I included this check because you have it, but it really should be part of your 'auth' middleware, most likely added as part of a route group. |
||
14 | return redirect(route('admin.login')); |
||
15 | } |
||
16 | // Perform action |
||
17 | $user = Auth::user(); |
||
18 | |||
19 | if ($user->admin == true) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
20 | return $next($request); |
||
21 | } else { |
||
22 | abort(403); |
||
23 | } |
||
24 | } |
||
25 | } |
||
26 |