function RestAuthenticationController::loginStatus

Same name and namespace in other branches
  1. 11.x core/modules/rest/src/Controller/RestAuthenticationController.php \Drupal\rest\Controller\RestAuthenticationController::loginStatus()

Checks whether a user is logged in or not.

Return value

\Symfony\Component\HttpFoundation\Response The response.

1 string reference to 'RestAuthenticationController::loginStatus'
rest.routing.yml in core/modules/rest/rest.routing.yml
core/modules/rest/rest.routing.yml

File

core/modules/rest/src/Controller/RestAuthenticationController.php, line 253

Class

RestAuthenticationController
Provides controllers for login, login status and logout via HTTP requests.

Namespace

Drupal\rest\Controller

Code

public function loginStatus() : Response {
  if ($this->currentUser()
    ->isAuthenticated()) {
    $response = new Response(self::LOGGED_IN);
  }
  else {
    $response = new Response(self::LOGGED_OUT);
  }
  $response->headers
    ->set('Content-Type', 'text/plain');
  return $response;
}

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