Skip to content

Commit

Permalink
Fixed returned type UserHelper::getCurrentUser (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciastektk authored Oct 27, 2021
1 parent 0cb9bce commit 064d76c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/Helper/UserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace EzSystems\EzRecommendationClient\Helper;

use eZ\Publish\Core\MVC\Symfony\Security\UserInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

Expand Down Expand Up @@ -41,10 +42,10 @@ public function getCurrentUser(): string
$authenticationToken = $this->tokenStorage->getToken();
$user = $authenticationToken->getUser();

if (\is_string($user)) {
if (is_string($user)) {
return $user;
} elseif (method_exists($user, 'getAPIUser')) {
return $user->getAPIUser()->id;
} elseif ($user instanceof UserInterface) {
return (string) $user->getAPIUser()->id;
}

return (string) $authenticationToken->getUsername();
Expand Down

0 comments on commit 064d76c

Please sign in to comment.