2020-02-10 12:16:34 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Api;
|
|
|
|
|
2020-04-02 00:02:51 +02:00
|
|
|
use \Driver\SQL\Keyword;
|
|
|
|
use \Driver\SQL\Condition\Compare;
|
|
|
|
|
2020-02-10 12:16:34 +01:00
|
|
|
class GetApiKeys extends Request {
|
|
|
|
|
|
|
|
public function __construct($user, $externCall = false) {
|
|
|
|
parent::__construct($user, $externCall, array());
|
|
|
|
$this->loginRequired = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute($values = array()) {
|
|
|
|
if(!parent::execute($values)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-02 00:02:51 +02:00
|
|
|
$sql = $this->user->getSQL();
|
|
|
|
$res = $sql->select("uid", "api_key", "valid_until")
|
|
|
|
->from("ApiKey")
|
|
|
|
->where(new Compare("user_id", $this->user->getId()))
|
|
|
|
->where(new Compare("valid_until", new Keyword($sql->currentTimestamp()), ">"))
|
|
|
|
->where(new Compare("active", true))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$this->success = ($res !== FALSE);
|
|
|
|
$this->lastError = $sql->getLastError();
|
2020-02-10 12:16:34 +01:00
|
|
|
|
|
|
|
if($this->success) {
|
2020-04-02 00:02:51 +02:00
|
|
|
$this->result["api_keys"] = $res;
|
2020-02-10 12:16:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->success;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
?>
|