function TestController::getCsrfToken

Same name in other branches
  1. 9 core/modules/system/tests/modules/csrf_race_test/src/Controller/TestController.php \Drupal\csrf_race_test\Controller\TestController::getCsrfToken()
  2. 8.9.x core/modules/system/tests/modules/csrf_race_test/src/Controller/TestController.php \Drupal\csrf_race_test\Controller\TestController::getCsrfToken()
  3. 11.x core/modules/system/tests/modules/csrf_race_test/src/Controller/TestController.php \Drupal\csrf_race_test\Controller\TestController::getCsrfToken()

Just return generated CSRF token for concurrent requests.

We delay the response to the first request to make sure the second request is made when the first is not yet finished.

Return value

\Symfony\Component\HttpFoundation\Response CSRF token.

1 string reference to 'TestController::getCsrfToken'
csrf_race_test.routing.yml in core/modules/system/tests/modules/csrf_race_test/csrf_race_test.routing.yml
core/modules/system/tests/modules/csrf_race_test/csrf_race_test.routing.yml

File

core/modules/system/tests/modules/csrf_race_test/src/Controller/TestController.php, line 62

Class

TestController
Controller to test concurrent CSRF token generation.

Namespace

Drupal\csrf_race_test\Controller

Code

public function getCsrfToken(int $num) {
    sleep($num);
    return new JsonResponse($this->tokenGenerator
        ->get());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.