request = $request; $this->user_storage = $user_storage; $this->api_wrapper = $api_wrapper; } /** * @return JSON_Response|Redirection_Response|View_Response * * @throws User_Not_Found_Exception * @throws API_Exception */ public function handle() { $user_id = $this->user_storage->get_user_id(); $user = $this->api_wrapper->get_integration_user_by_external_id( $user_id ); if ( is_null( $user ) ) { if ( $this->request->is_ajax() ) { return $this->json( array( 'error' => 'Integration user not found.', ), 403 ); } return $this->redirection( Route::SUBMENU_CHANNEL ); } return $this->next->handle(); } }