ringfinger/backend/classes/controller/UserSessionDeleteController.php

26 lines
571 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();
if (!$this->session->IsLoggedIn()) {
$this->response = new ApiJsonResponse(ServerStatus::BAD_REQUEST);
$this->response->setParameter('success', false);
$this->response->setMessage('No session to delete!');
return;
}
$this->session->Destroy();
$this->response = new ApiJsonResponse();
$this->response->setParameter('success', true);
}
}