\Drupal::currentUser() returns information about the anonymous user, even though I am logged in
To determine if a user is logged-in (authenticated), it would be best to use:

\Drupal::currentUser()-&gt;isAuthenticated()