1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-01-09 06:05:28 +01:00
openstamanager/modules/utenti/api/v1/Logout.php
2019-07-19 16:51:52 +02:00

27 lines
691 B
PHP

<?php
namespace Modules\Utenti\API\v1;
use API\Interfaces\CreateInterface;
use API\Resource;
class Logout extends Resource implements CreateInterface
{
public function create($request)
{
$database = database();
$user = $this->getUser();
if (!empty($request['token']) && !empty($user)) {
// Cancellazione della chiave
$database->query('DELETE FROM `zz_tokens` WHERE `token` = '.prepare($request['token']).' AND `id_utente` = '.prepare($user['id']));
} else {
$response = [
'status' => API\Response::getStatus()['unauthorized']['code'],
];
}
return $response;
}
}