ringfinger/backend/classes/controller/UserSessionDeleteController...

28 lines
588 B
PHP

<?php
declare(strict_types=1);
final class UserSessionDeleteController extends AbstractController
{
protected string $route = '/api/v1/user/session';
public function handle(): void
{
parent::handle();
$session = new Session();
if (!$session->IsLoggedIn()) {
$this->response = new ApiJsonResponse(ServerStatus::BAD_REQUEST);
$this->response->setParameter('success', false);
$this->response->setMessage('No session to delete!');
return;
}
$session->Destroy();
$this->response = new ApiJsonResponse();
$this->response->setParameter('success', true);
}
}