Skip to content

Commit

Permalink
Fix the CI chain
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jan 17, 2024
1 parent 47ba88f commit 72953da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 38 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -30,7 +30,7 @@
"forum": "https://community.contao.org"
},
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"contao/core-bundle": "^4.13 || ^5.0",
"symfony/security-core": "^5.3 || ^6",
"symfony/http-foundation": "^5.3 || ^6",
Expand Down
53 changes: 16 additions & 37 deletions src/EventListener/RegistrationListener.php
Expand Up @@ -4,8 +4,8 @@

namespace Terminal42\AutoRegistrationBundle\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\CoreBundle\Monolog\ContaoContext;
use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\FrontendUser;
use Contao\MemberModel;
use Contao\ModuleRegistration;
Expand All @@ -26,42 +26,22 @@

class RegistrationListener
{
private UserProviderInterface $userProvider;

private TokenStorageInterface $tokenStorage;

private Connection $connection;

private LoggerInterface $logger;

private EventDispatcherInterface $eventDispatcher;

private RequestStack $requestStack;

private UserCheckerInterface $userChecker;

private AuthenticationSuccessHandlerInterface $authenticationSuccessHandler;

/**
* RegistrationListener constructor.
*/
public function __construct(UserProviderInterface $userProvider, TokenStorageInterface $tokenStorage, Connection $connection, LoggerInterface $logger, EventDispatcherInterface $eventDispatcher, RequestStack $requestStack, UserCheckerInterface $userChecker, AuthenticationSuccessHandlerInterface $authenticationSuccessHandler)
{
$this->userProvider = $userProvider;
$this->tokenStorage = $tokenStorage;
$this->connection = $connection;
$this->logger = $logger;
$this->eventDispatcher = $eventDispatcher;
$this->requestStack = $requestStack;
$this->userChecker = $userChecker;
$this->authenticationSuccessHandler = $authenticationSuccessHandler;
public function __construct(
private readonly UserProviderInterface $userProvider,
private readonly TokenStorageInterface $tokenStorage,
private readonly Connection $connection,
private readonly LoggerInterface $logger,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly RequestStack $requestStack,
private readonly UserCheckerInterface $userChecker,
private readonly AuthenticationSuccessHandlerInterface $authenticationSuccessHandler,
) {
}

/**
* Within the registration process, log in the user if needed.
*
* @Hook("createNewUser")
*/
#[AsHook('createNewUser')]
public function onCreateNewUser(int $userId, array &$data, ModuleRegistration $module): void
{
if ('activate' !== $module->reg_autoActivate && 'login' !== $module->reg_autoActivate) {
Expand All @@ -78,9 +58,8 @@ public function onCreateNewUser(int $userId, array &$data, ModuleRegistration $m

/**
* Within the activation process, log in the user if needed.
*
* @Hook("activateAccount")
*/
#[AsHook('activateAccount')]
public function onActivateAccount(MemberModel $member, ModuleRegistration $module): void
{
if ($module->reg_activateLogin) {
Expand All @@ -95,7 +74,7 @@ private function loginUser(string $username): void
{
try {
$user = $this->userProvider->loadUserByIdentifier($username);
} catch (UserNotFoundException $exception) {
} catch (UserNotFoundException) {
return;
}

Expand All @@ -106,11 +85,11 @@ private function loginUser(string $username): void
try {
$this->userChecker->checkPreAuth($user);
$this->userChecker->checkPostAuth($user);
} catch (AccountStatusException $e) {
} catch (AccountStatusException) {
return;
}

$usernamePasswordToken = new UsernamePasswordToken($user, null, 'frontend', $user->getRoles());
$usernamePasswordToken = new UsernamePasswordToken($user, 'frontend', $user->getRoles());
$this->tokenStorage->setToken($usernamePasswordToken);

$event = new InteractiveLoginEvent($this->requestStack->getCurrentRequest(), $usernamePasswordToken);
Expand Down

0 comments on commit 72953da

Please sign in to comment.