phpmyadmin/libraries/classes/Controllers/LogoutController.php
Maurício Meneghini Fauth a2a3f6d26d
Create a factory for auth plugin creation
Extracts the factory method from the Plugins class into a new class.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-11-16 19:32:10 -03:00

33 lines
748 B
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\Core;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Plugins\AuthenticationPluginFactory;
class LogoutController
{
/** @var AuthenticationPluginFactory */
private $authPluginFactory;
public function __construct(AuthenticationPluginFactory $authPluginFactory)
{
$this->authPluginFactory = $authPluginFactory;
}
public function __invoke(ServerRequest $request): void
{
if (! $request->isPost() || $GLOBALS['token_mismatch']) {
Core::sendHeaderLocation('./index.php?route=/');
return;
}
$authPlugin = $this->authPluginFactory->create();
$authPlugin->logOut();
}
}