Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
App\EventSubscriber\InteractiveLoginSubscriber:
arguments:
$userProvider: '@ibexa.security.user_provider.username'
$userMap:
from_memory_user: customer
from_memory_admin: admin
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

namespace App\EventSubscriber;

use Ibexa\Contracts\Core\Repository\UserService;
use Ibexa\Core\MVC\Symfony\Security\User;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\SecurityEvents;

class InteractiveLoginSubscriber implements EventSubscriberInterface
{
/** @param array<string, string> $userMap */
public function __construct(

Check failure on line 14 in code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php

View workflow job for this annotation

GitHub Actions / Validate code samples (8.3)

Method App\EventSubscriber\InteractiveLoginSubscriber::__construct() has parameter $userProvider with generic interface Symfony\Component\Security\Core\User\UserProviderInterface but does not specify its types: TUser
private readonly UserService $userService,
private readonly UserProviderInterface $userProvider,
private readonly array $userMap = [],
) {
}
Expand All @@ -30,8 +29,8 @@
$tokenUser = $event->getAuthenticationToken()->getUser();
if ($tokenUser instanceof InMemoryUser) {
$userLogin = $this->userMap[$event->getAuthenticationToken()->getUserIdentifier()] ?? 'anonymous';
$ibexaUser = $this->userService->loadUserByLogin($userLogin);
$event->getAuthenticationToken()->setUser(new User($ibexaUser));
$wrappedUser = $this->userProvider->loadUserByIdentifier($userLogin);
$event->getAuthenticationToken()->setUser($wrappedUser);
}
}
}
Loading