CoreFiles by mySites.guru
AjaxChallenge.php44 lines, 1,111 bytes, from Joomla_4.2.0-Stable-Full_Package.zip
Raw History Compare with 4.1.5
md5
31d0c39bfddd703037f4e584d4419333
sha1
83a80e3cf6abdef28670354fdb724863b92e3c33
sha256
9917682bb7bb460d49e7b9f06c9c85d02bc1f41e0033e96ba4683af06a40fd7e
<?php

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

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

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

/**
 * 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 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.