28 lines
675 B
PHP
28 lines
675 B
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
final class UserLogoutPutController extends AbstractController
|
||
|
{
|
||
|
protected string $route = '/api/v1/user/logout';
|
||
|
|
||
|
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('You were not logged in!');
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$session->Destroy();
|
||
|
|
||
|
$this->response = new ApiJsonResponse();
|
||
|
$this->response->setParameter('success', true);
|
||
|
}
|
||
|
}
|