/**
  * @param Request $request
  * @param Closure $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     //Generate the request id
     $requestId = Uuid::uuid1()->toString();
     //Add the request id processor to logger instance
     $this->log->addProcessors([new RequestIdProcessor($requestId)]);
     $response = $next($request);
     $response->headers->set('Request-Id', $requestId, false);
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Handle middleware
  *
  * @param Request $request
  * @param callable $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     //Get account
     $account = $this->getAccountFromRouting();
     //Set account in context
     $this->context->setAccount($account);
     //If the owner type is User
     if ($this->authorizer->getResourceOwnerType() == 'user') {
         //Find the user
         $user = $this->userRepository->find($this->authorizer->getResourceOwnerId());
         //If we have account in the route
         if ($account) {
             //Check if the user has access to the account
             if (!$user->isAssociateToAccount($account)) {
                 return $this->response->errorUnauthorized("You don't have access to the account {$account->uuid}");
             }
         }
         //Add context processor to log
         $this->log->addProcessors([new ContextProcessor($user, isset($account) ? $account : null)]);
         //Set the user in context
         $this->context->setUser($user);
     }
     // Set application locale
     $this->setApplicationLocale();
     return $next($request);
 }
 /**
  * @param $event
  */
 public function handle($event)
 {
     $this->log->channel('event')->info('Event fired : [' . get_class($event) . '] ' . json_encode($event));
 }