plugin_status = $plugin_status; $this->flash = $flash; $this->request = $request; } /** * @return null|View_Response|Redirect_Response|JSON_Response */ public function handle() { if ( ! $this->plugin_status->client_completed_registration() ) { if ( current_user_can( Capabilities::ADMIN ) ) { return $this->get_admin_response(); } return $this->get_user_response(); } return $this->next->handle(); } /** * @return JSON_Response|Redirect_Response */ private function get_admin_response() { if ( $this->request->is_ajax() ) { return $this->json( [ 'error' => "2FAS account doesn't exist", ], 403 ); } $this->flash->add_message( 'error', 'account-required' ); return $this->redirect( new Action_URL( Action_Index::SUBMENU_DASHBOARD, Action_Index::ACTION_CREATE_ACCOUNT ) ); } /** * @return JSON_Response|View_Response */ private function get_user_response() { if ( $this->request->is_ajax() ) { return $this->json( [ 'error' => "2FAS account doesn't exist", ], 403 ); } return $this->view( Views::NOT_ENABLED ); } }