add Froxlor.integrityCheck() API call to externally run integrity/consistency check, fixes #801

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2020-02-15 07:30:56 +01:00
parent 03450dcfa2
commit d6c8b92523

View File

@@ -243,6 +243,26 @@ class Froxlor extends \Froxlor\Api\ApiCommand
return $this->response(200, "successfull", \Froxlor\System\Crypt::generatePassword());
}
/**
* can be used to remotely run the integritiy checks froxlor implements
*
* @access admin
* @throws \Exception
* @return string
*/
public function integrityCheck()
{
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
$integrity = new \Froxlor\Database\IntegrityCheck();
$result = $integrity->checkAll();
if ($result) {
return $this->response(200, "successfull", "OK");
}
throw new \Exception("Some checks failed.", 406);
}
throw new \Exception("Not allowed to execute given command.", 403);
}
/**
* returns a list of all available api functions
*