CoreFiles by mySites.guru
AjaxChallenge.php47 lines, 1,199 bytes, from Joomla_5.2.2-Stable-Full_Package.zip
Raw History Compare with 5.2.1
md5
fc7c007b38bbda96e55103f06ce0a5fc
sha1
4861814d183af5a1c267144f3ac719800be91d5f
sha256
c8936377cd514b4b52542b1967bb4a968168d49987364c7d20a1de223b423c4d
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Event\Plugin\System\Webauthn;

use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Concrete event class for the onAjaxWebauthnChallenge event
 *
 * @since  4.2.0
 */
class AjaxChallenge extends AbstractImmutableEvent implements ResultAwareInterface
{
    use ResultAware;

    /**
     * Make sure the result is valid JSON or boolean false
     *
     * @param   mixed  $data  The data to check
     *
     * @return  void
     * @since   4.2.0
     */
    public function typeCheckResult($data): void
    {
        if ($data === false) {
            return;
        }

        if (!\is_string($data) || @json_decode($data) === null) {
            throw new \InvalidArgumentException(\sprintf('Event %s only accepts JSON results.', $this->getName()));
        }
    }
}

The same content is in 112 releases, Joomla 5.2.0-beta3 to 6.2.1-rc1. See them all, or every version of this file.