src/snac/client/webui/WebUIExecutor.php
/**
     * Display API Key Management
     *
     * API Key management function.  Displays the API key information page and handles subcommands
     * for generating and revoking API keys.
     *
     * @param string[] $input Post/Get inputs from the webui
     * @param \snac\client\webui\display\Display $display The display object for page creation
     * @param \snac\data\User $user The current user object
     */
Display API Key Management
API Key management function.  Displays the API key information page and handles subcommands
for generating and revoking API keys.


Display API Key Management API Key management function . Displays the API key information page and handles subcommands for generating and revoking API keys .
public function displayAPIInfoPage(&$input, &$display, &$user) {
        $command = "view";
        if (isset($input["subcommand"]))
            $command = $input["subcommand"];
        switch($command) {
            case "generate":
                $display->setTemplate("api_key_generate");
                $ask = array("command"=>"generate_key_user");
                $this->logger->addDebug("Sending query to the server", $ask);
                $serverResponse = $this->connect->query($ask);
                $this->logger->addDebug("Received server response", [$serverResponse]);
                $this->logger->addDebug("Setting api key data into the page template");
                $display->setData($serverResponse);
                $this->logger->addDebug("Finished setting api key data into the page template");
                $this->reloadUser();
                break;
            case "revoke":
                $display->setTemplate("api_keys");
                $data = [
                    "restURL" => \snac\Config::$REST_URL
                ];
                if (isset($input["label"])) {
                    $ask = array(
                        "command"=>"revoke_key_user",
                        "apikey_label" => $input["label"]
                    );
                    $this->logger->addDebug("Sending query to the server", $ask);
                    $serverResponse = $this->connect->query($ask);
                    $this->logger->addDebug("Received server response", [$serverResponse]);
                    $this->logger->addDebug("Setting data into the page template");
                    if (isset($serverResponse["result"]) && $serverResponse["result"] == "success") {
                        $data["message"] = "Successfully revoked key <strong>" . $input["label"] . "</strong>";
                        $data["messageType"] = "success";
                    } else {
                        $data["message"] = "Error revoking key <strong>" . $input["label"] . "</strong>";
                        $data["messageType"] = "danger";
                    }
                } else {
                    $data["message"] = "No API Key label given to revoke";
                    $data["messageType"] = "warning";
                }
                $display->setData($data);
                $this->reloadUser();
                $this->logger->addDebug("Finished setting api key data into the page template");
                break;
            default:
                $display->setTemplate("api_keys");
                $display->setData([
                    "restURL" => \snac\Config::$REST_URL
                ]);
        }
    }
public function displayAPIInfoPage ( & $ input , & $ display , & $ user ) { $ command = " view " ; if ( isset ( $ input [ " subcommand " ] ) ) $ command = $ input [ " subcommand " ] ; switch ( $ command ) { case " generate " : $ display -> setTemplate ( " api_key_generate " ) ; $ ask = array ( " command " => " generate_key_user " ) ; $ this -> logger -> addDebug ( " Sending query to the server " , $ ask ) ; $ serverResponse = $ this -> connect -> query ( $ ask ) ; $ this -> logger -> addDebug ( " Received server response " , [ $ serverResponse ] ) ; $ this -> logger -> addDebug ( " Setting api key data into the page template " ) ; $ display -> setData ( $ serverResponse ) ; $ this -> logger -> addDebug ( " Finished setting api key data into the page template " ) ; $ this -> reloadUser ( ) ; break ; case " revoke " : $ display -> setTemplate ( " api_keys " ) ; $ data = [ " restURL " => \ snac \ Config :: $ REST_URL ] ; if ( isset ( $ input [ " label " ] ) ) { $ ask = array ( " command " => " revoke_key_user " , " apikey_label " => $ input [ " label " ] ) ; $ this -> logger -> addDebug ( " Sending query to the server " , $ ask ) ; $ serverResponse = $ this -> connect -> query ( $ ask ) ; $ this -> logger -> addDebug ( " Received server response " , [ $ serverResponse ] ) ; $ this -> logger -> addDebug ( " Setting data into the page template " ) ; if ( isset ( $ serverResponse [ " result " ] ) && $ serverResponse [ " result " ] == " success " ) { $ data [ " message " ] = " Successfully revoked key <strong> " . $ input [ " label " ] . " </strong> " ; $ data [ " messageType " ] = " success " ; } else { $ data [ " message " ] = " Error revoking key <strong> " . $ input [ " label " ] . " </strong> " ; $ data [ " messageType " ] = " danger " ; } } else { $ data [ " message " ] = " No API Key label given to revoke " ; $ data [ " messageType " ] = " warning " ; } $ display -> setData ( $ data ) ; $ this -> reloadUser ( ) ; $ this -> logger -> addDebug ( " Finished setting api key data into the page template " ) ; break ; default : $ display -> setTemplate ( " api_keys " ) ; $ display -> setData ( [ " restURL " => \ snac \ Config :: $ REST_URL ] ) ; } }
Display API Key Management
 API Key management function.
Display API Key Management API Key management function .