2020-08-17 23:46:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-08-21 23:16:24 +02:00
|
|
|
final class UserSessionDeleteController extends AbstractController
|
2020-08-17 23:46:58 +02:00
|
|
|
{
|
2020-08-23 12:37:39 +02:00
|
|
|
protected string $route = '/api/v1/user/session';
|
2020-08-17 23:46:58 +02:00
|
|
|
|
2020-08-23 12:37:39 +02:00
|
|
|
public function handle(): void
|
|
|
|
{
|
|
|
|
parent::handle();
|
2020-08-17 23:46:58 +02:00
|
|
|
|
2020-08-24 22:19:46 +02:00
|
|
|
if (!$this->session->IsLoggedIn()) {
|
2020-08-23 12:37:39 +02:00
|
|
|
$this->response = new ApiJsonResponse(ServerStatus::BAD_REQUEST);
|
|
|
|
$this->response->setParameter('success', false);
|
|
|
|
$this->response->setMessage('No session to delete!');
|
2020-08-17 23:46:58 +02:00
|
|
|
|
2020-08-23 12:37:39 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-08-17 23:46:58 +02:00
|
|
|
|
2020-08-24 22:19:46 +02:00
|
|
|
$this->session->Destroy();
|
2020-08-17 23:46:58 +02:00
|
|
|
|
2020-08-23 12:37:39 +02:00
|
|
|
$this->response = new ApiJsonResponse();
|
|
|
|
$this->response->setParameter('success', true);
|
|
|
|
}
|
2020-08-17 23:46:58 +02:00
|
|
|
}
|