getHeaderLine('Authorization'); if (empty($authorization)){ return $this->response->json( $this->apiReturn->error(ApiCode::getMessage(ApiCode::LOGIN_ERROR), ApiCode::LOGIN_ERROR) ); } $authorization = str_replace("Bearer ", "", $authorization); $userJwt = $this->cryptoFactory->cryptoClass('jwt', $authorization)->decrypt(); if (empty($userJwt)) { return $this->response->json( $this->apiReturn->error(ApiCode::getMessage(ApiCode::LOGIN_TOKEN_ERROR), ApiCode::LOGIN_TOKEN_ERROR) ); } $userId = $userJwt['data']->id; if ($this->userCache->getUserToken($userId) != $authorization) { return $this->response->json( $this->apiReturn->error(ApiCode::getMessage(ApiCode::LOGIN_TOKEN_ERROR), ApiCode::LOGIN_TOKEN_ERROR) ); } Context::set('user_id',$userId); return $handler->handle($request); } }