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

20 lines
594 B
PHP
Raw Normal View History

2021-01-03 12:29:41 +01:00
<?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'));
}
}
?>