Handle an incoming request.

@param \Illuminate\Http\Request $request
@param \Closure $next
@param string|null $guard

@return mixed
180964
public function handle($request, Closure $next, $guard = 'admin')
    {
        if (Auth::guard($guard)->guest()) {
            return JsonResponse::create(['message' => 'you are not authorized to access this api', 'status' => false], 401);
        }

        $user = Auth::user();
        if (isset($user->language) && ! empty($user->language)) {
            App::setLocale($user->language);
        }

        return $next($request);
    }
805307
public function handle($request, Closure $next)
    {
        if( auth()->check() ) {
            $user = auth()->user();
            $user->updateLastActivity();
        }

        return $next($request);
    }
1082528
public function handle($request, Closure $next)
    {
        $this->aclPolicy->defineAbilities();

        if ( ! $this->aclPolicy->passesAuthorization() ) {
            abort(403, config('acl.unauthorized_message'));
        }

        return $next($request);
    }
483602
public function handle($request, Closure $next)
    {
        $result = Authenticate::handle($request, $next);
        if (!($result instanceof Closure)) {
            return errors(['Unauthorize']);
        }
        if (Auth::role('id') != (new Config)->value('users_roles', 'admin_role')) {
            return errors(['Permission denied']);
        }
        return $next($request);
    }
1010786
public function handle($request, Closure $next, $guard = null)
    {
        $apiKeyValue = $request->header(config('apiguard.header_key', 'X-Authorization'));

        $apiKey = app(config('apiguard.models.api_key', 'Chrisbjr\ApiGuard\Models\ApiKey'))->where('key', $apiKeyValue)
            ->first();

        if (empty($apiKey)) {
            return $this->unauthorizedResponse();
        }

        // Update this api key's last_used_at and last_ip_address
        $apiKey->update([
            'last_used_at'    => Carbon::now(),
            'last_ip_address' => $request->ip(),
        ]);

        $apikeyable = $apiKey->apikeyable;

        // Bind the user or object to the request
        // By doing this, we can now get the specified user through the request object in the controller using:
        // $request->user()
        $request->setUserResolver(function () use ($apikeyable) {
            return $apikeyable;
        });

        // Attach the apikey object to the request
        $request->apiKey = $apiKey;

        event(new ApiKeyAuthenticated($request, $apiKey));

        return $next($request);
    }
613033
public function handle($request, Closure $next)
    {
        try {
            if ($user = $this->auth->authenticate()) {
                $request->setUserResolver(function () use ($user) {
                    return $user;
                });
            }
        } catch (AuthenticationException $e) {
            // do nothing
        }

        return $next($request);
    }
268531
public function handle($request, Closure $next, ...$guards)
    {
        try {
            if(sharp_laravel_version_gte('5.7')) {
                // Laravel's API changed in 5.7
                // @see https://laravel.com/docs/5.7/upgrade
                $this->authenticate($request, $guards);

            } else {
                $this->authenticate($guards);
            }

            if($checkHandler = config('sharp.auth.check_handler')) {
                if(!app($checkHandler)->check(auth()->guard($guards[0] ?? null)->user())) {
                    throw new AuthenticationException();
                }
            }

        } catch (AuthenticationException $e) {
            if($request->wantsJson()) {
                return response()->json(['message' => "Unauthenticated user"], 401);
            }

            return redirect()->guest(
                config('sharp.auth.login_page_url', route("code16.sharp.login"))
            );
        }

        return $next($request);
    }
1159509
public function handle($request, Closure $next, $guard = null, $field = null)
    {
        if (!App::environment(config('auth.environments', ['staging']))) {
            return $next($request);
        }

        return parent::handle($request, $next, $guard);
    }
111954
public function handle($request, Closure $next, $guard = null)
    {
        /** @var  \Arcanedev\LaravelAuth\Models\User  $user */
        $user = Auth::guard($guard)->user();

        if ( ! is_null($user) && $this->isEnabled())
            $user->updateLastActivity();

        return $next($request);
    }
957803
public function handle($request, Closure $next, $guard = null)
    {
        if (auth()->guard($guard)->check()) {
            return intend([
                'url' => route($request->route('accessarea').'.home'),
                'with' => ['success' => trans('cortex/foundation::messages.already_authenticated')],
            ]);
        }

        return $next($request);
    }
185657
public function handle($request, Closure $next, $guard = null)
    {
        try {
            $authinfo = \Besofty\Web\Attendance\Model\User::details(\Session::get('authinfo'));
            $roleID = \Besofty\Web\Attendance\Model\UsersRole::getRoleID($authinfo['id']);
            $userRole = \Besofty\Web\Attendance\Model\Role::getName($roleID['role_id']);
            $isAdmin = Role::isAdmin($userRole['slug']);

            if ($isAdmin['slug'] != 'super-administrator' && $isAdmin['slug'] != 'administrator' ) {
                return redirect('/logout');
            }
            return $next($request);
        } catch (\Exception $exception) {
            throw $exception;
        }
    }
92410
public function handle(Request $request, Closure $next)
    {
        $asset = $request->route()->parameter('asset');

        if (!$asset->isPublic() && !$this->guard->check()) {
            abort(401);
        }

        if (!Asset::exists($asset)) {
            abort(404);
        }

        return $next($request);
    }
690363
public function handle($request, Closure $next)
    {
        if (Auth::check() && Auth::user()->hasRole("Admin")) {
        return $next($request);
        }
        return redirect('login');
        // return Redirect::back();

    }
682655
public function handle($request, Closure $next, ...$guards)
    {
        $this->authenticate($request, $guards);

        return $next($request);
    }
1035872
public function handle(Request $request, Closure $next)
    {
        // 1. Check global permission
        $rule = $this->settings->get('permission');

        $response = $this->guard->isPermissionGranted(
            app($rule)->validate()
        );

        if (!$response) {
            auth('admin')->logout();

            return response()
                ->redirectGuest($this->loginUrl)
                ->with('redirect', $request->url());
        }

        if ($this->isResponseObject($response)) {
            return $response;
        }

        if ($this->redirectReceived($response)) {
            return $response->with('redirect', $request->url());
        }

        return $next($request);
    }
26739
public function handle($request, Closure $next, $guard = 'admin')
    {
        config(['auth.defaults.guard' => 'admin']);

        $permissionName = $request->route()->getName();

        if (in_array($permissionName, ['admin.login', 'admin.login.post',
            'admin.password.reset.token', 'admin.password.email.post',
            'admin.password.reset.token', 'admin.password.reset',
        ])) {
            return $next($request);
        }

        if (Auth::guard($guard)->user()->is_super_admin == 1) {
            return $next($request);
        }

        $user = Auth::guard('admin')->user();

        if (!$user->hasPermission($permissionName)) {
            throw new \Exception('User Don\'t have permissions', 401);
        }

        return $next($request);
    }
951150
public function handle($request, Closure $next, $permission)
    {
        if (!Sentinel::check()) {
            return $this->denied($request);
        }

        if (!Sentinel::hasAccess($permission)) {
            return $this->denied($request);
        }

        return $next($request);
    }