Moved provisioning change function into controller from helper
This commit is contained in:
parent
bd72252e9e
commit
2ec2403cce
|
@ -73,32 +73,6 @@ class ProvisioningHelper
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Endpoint to change Airtime preferences remotely.
|
|
||||||
* Mainly for use with the dashboard right now.
|
|
||||||
*/
|
|
||||||
public function changeAction() {
|
|
||||||
$apikey = $_SERVER['PHP_AUTH_USER'];
|
|
||||||
if (!isset($apikey) || $apikey != $this->apikey) {
|
|
||||||
Logging::info("Invalid API Key: $apikey");
|
|
||||||
http_response_code(403);
|
|
||||||
echo "ERROR: Incorrect API key";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$this->parsePostParams();
|
|
||||||
$this->initializePrefs();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
http_response_code(400);
|
|
||||||
Logging::error($e->getMessage());
|
|
||||||
echo $e->getMessage() . PHP_EOL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
http_response_code(201);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the database settings and credentials given are valid
|
* Check if the database settings and credentials given are valid
|
||||||
* @return boolean true if the database given exists and the user is valid and can access it
|
* @return boolean true if the database given exists and the user is valid and can access it
|
||||||
|
@ -124,6 +98,7 @@ class ProvisioningHelper
|
||||||
// Result is either boolean FALSE (no table found) or PDOStatement Object (table found)
|
// Result is either boolean FALSE (no table found) or PDOStatement Object (table found)
|
||||||
return $result !== FALSE;
|
return $result !== FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parsePostParams()
|
private function parsePostParams()
|
||||||
{
|
{
|
||||||
$this->dbuser = $_POST['dbuser'];
|
$this->dbuser = $_POST['dbuser'];
|
||||||
|
|
|
@ -18,6 +18,40 @@ class ProvisioningController extends Zend_Controller_Action
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endpoint to change Airtime preferences remotely.
|
||||||
|
* Mainly for use with the dashboard right now.
|
||||||
|
*/
|
||||||
|
public function changeAction() {
|
||||||
|
$this->view->layout()->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender(true);
|
||||||
|
|
||||||
|
if (!RestAuth::verifyAuth(true, true, $this)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// This is hacky and should be genericized
|
||||||
|
if ($_POST['station_name']) {
|
||||||
|
Application_Model_Preference::SetStationName($_POST['station_name']);
|
||||||
|
}
|
||||||
|
if ($_POST['station_name']) {
|
||||||
|
Application_Model_Preference::SetStationDescription($_POST['station_name']);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->getResponse()
|
||||||
|
->setHttpResponseCode(400)
|
||||||
|
->appendBody("ERROR: " . $e->getMessage());
|
||||||
|
Logging::error($e->getMessage());
|
||||||
|
echo $e->getMessage() . PHP_EOL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getResponse()
|
||||||
|
->setHttpResponseCode(200)
|
||||||
|
->appendBody("OK");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the Airtime Pro station's files from Amazon S3
|
* Delete the Airtime Pro station's files from Amazon S3
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue