juggl/public/api/services/authenticator.inc.php

20 lines
No EOL
594 B
PHP

<?php
require_once(__DIR__."/dbOperations.inc.php");
class Authenticator {
function isApiKeyAuthenticated($api_key, $user_id) {
$db = new DbOperations();
$db->select("api_keys", ["enabled"]);
$db->where("api_key", Comparison::EQUAL, $api_key);
$db->where("user_id", Comparison::EQUAL, $user_id);
$result = $db->execute();
return count($result) == 1 && $result[0]['enabled'];
}
function isAuthenticated($params) {
return $this->isApiKeyAuthenticated($params->get('api_key'), $params->get('user_id'));
}
}
?>