You are here

public function TestController::getCsrfToken in Drupal 8

Same name and namespace in other branches
  1. 9 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($num) {
  sleep($num);
  return new JsonResponse($this->tokenGenerator
    ->get());
}