<?php
/**
 * @package   BaForms
 * @author    Balbooa http://www.balbooa.com/
 * @copyright Copyright @ Balbooa
 * @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
 */

namespace Balbooa\Component\Forms\Administrator\Controller\Trait;

defined('_JEXEC') or die;

use Balbooa\Component\Forms\Administrator\Exceptions\InvalidTokenException;
use Joomla\CMS\Session\Session;

trait HasSessionTokenCheck
{
    public function execute($task)
    {
        if ($this->input->getMethod() === 'POST' && !Session::checkToken()) {
            throw new InvalidTokenException();
        }

        return parent::execute($task);
    }
}