chamilo/chamilo-lms

View on GitHub
public/plugin/xapi/cmi5/token.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

/* For licensing terms, see /license.txt */

use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Symfony\Component\HttpFoundation\Response;

require_once __DIR__.'/../../../main/inc/global.inc.php';

$request = HttpRequest::createFromGlobals();

$response = new JsonResponse([], Response::HTTP_METHOD_NOT_ALLOWED);

if ('POST' === $request->getMethod()) {
    $token = base64_encode(uniqid());

    $response->setStatusCode(Response::HTTP_OK);
    $response->setData(['auth-token' => $token]);
}

$response->send();