12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Log;
- class Admin
- {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next, $guard = null)
- {
- $auth = Auth::guard($guard);
- if (Auth::guard($guard)->guest()) {
- if ($request->ajax() || $request->wantsJson()) {
- return response('Unauthorized.', 401);
- } else {
- return redirect()->guest('/');
- }
- }
- if ($auth->user()->email != 'admin@geolook.com') {
- return abort(404);
- }
- return $next($request);
- }
- }
|