40 lines
910 B
PHP
40 lines
910 B
PHP
<?php
|
|
|
|
namespace com\fwdekker\deathnotifier\user;
|
|
|
|
use com\fwdekker\deathnotifier\Action;
|
|
use com\fwdekker\deathnotifier\ActionException;
|
|
use com\fwdekker\deathnotifier\ActionMethod;
|
|
use com\fwdekker\deathnotifier\Util;
|
|
use com\fwdekker\deathnotifier\validator\IsEmailRule;
|
|
use Exception;
|
|
use Monolog\Logger;
|
|
|
|
|
|
class LogoutAction extends Action
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct(
|
|
ActionMethod::POST,
|
|
"logout",
|
|
require_logged_in: true,
|
|
require_valid_csrf_token: true,
|
|
);
|
|
}
|
|
|
|
|
|
function handle(): mixed
|
|
{
|
|
session_destroy();
|
|
session_start();
|
|
try {
|
|
$_SESSION["token"] = Util::generate_csrf_token();
|
|
} catch (Exception) {
|
|
throw new ActionException("Failed to generate new CSRF token. Please try again later.", null);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|