1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kanboard_ynh.git synced 2024-09-03 19:36:17 +02:00
kanboard_ynh/sources/app/Middleware/PostAuthenticationMiddleware.php
2016-07-23 14:11:39 +02:00

36 lines
1 KiB
PHP

<?php
namespace Kanboard\Middleware;
use Kanboard\Core\Controller\BaseMiddleware;
/**
* Class PostAuthenticationMiddleware
*
* @package Kanboard\Middleware
* @author Frederic Guillot
*/
class PostAuthenticationMiddleware extends BaseMiddleware
{
/**
* Execute middleware
*/
public function execute()
{
$controller = strtolower($this->router->getController());
$action = strtolower($this->router->getAction());
$ignore = ($controller === 'twofactorcontroller' && in_array($action, array('code', 'check'))) || ($controller === 'authcontroller' && $action === 'logout');
if ($ignore === false && $this->userSession->hasPostAuthentication() && ! $this->userSession->isPostAuthenticationValidated()) {
$this->nextMiddleware = null;
if ($this->request->isAjax()) {
$this->response->text('Not Authorized', 401);
}
$this->response->redirect($this->helper->url->to('TwoFactorController', 'code'));
}
$this->next();
}
}