2026-03-04 15:56:58 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Service\User;
|
|
|
|
|
|
|
|
|
|
use MintyPHP\Service\Access\AccessServicesFactory;
|
|
|
|
|
use MintyPHP\Service\Access\PermissionGateway;
|
2026-03-05 11:17:42 +01:00
|
|
|
use MintyPHP\Service\Directory\DirectoryRepositoryFactory;
|
2026-03-06 00:44:52 +01:00
|
|
|
use MintyPHP\Service\Settings\SettingsAppGateway;
|
|
|
|
|
use MintyPHP\Service\Settings\SettingsDefaultsGateway;
|
test(auth): add 33 unit tests for AuthService and RememberMeService
AuthServiceTest (17 tests): canLoginToTenant, refreshSessionAuthState,
loginUserById, login email-not-verified branch.
RememberMeServiceTest (16 tests): rememberUser, autoLoginFromCookie
(all 11 branches), forgetCurrentUser, forgetAllForUser,
expireAllTokensByAdmin.
Also fixes: 3 PHPStan errors in FrontendTelemetryIngestService,
8 CS-Fixer violations in out-of-scope files (ordered_imports,
braces_position).
All quality gates green: QG-001 (429 tests/0 failures),
QG-002 (0 errors), QG-003 (11 arch tests pass), QG-006 (0 violations).
Task: AUTH-LOGIN-REVIEW-001
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 11:43:31 +01:00
|
|
|
use MintyPHP\Service\Settings\SettingServicesFactory;
|
2026-03-06 00:44:52 +01:00
|
|
|
use MintyPHP\Service\Settings\SettingsUserLifecycleGateway;
|
2026-03-04 15:56:58 +01:00
|
|
|
use MintyPHP\Service\Tenant\TenantScopeService;
|
|
|
|
|
|
|
|
|
|
class UserGatewayFactory
|
|
|
|
|
{
|
2026-03-06 00:44:52 +01:00
|
|
|
private ?SettingsDefaultsGateway $settingsDefaultsGateway = null;
|
|
|
|
|
private ?SettingsAppGateway $settingsAppGateway = null;
|
|
|
|
|
private ?SettingsUserLifecycleGateway $settingsUserLifecycleGateway = null;
|
2026-03-04 15:56:58 +01:00
|
|
|
private ?PermissionGateway $permissionGateway = null;
|
|
|
|
|
private ?UserSettingsGateway $userSettingsGateway = null;
|
|
|
|
|
private ?UserScopeGateway $userScopeGateway = null;
|
|
|
|
|
private ?UserDirectoryGateway $userDirectoryGateway = null;
|
|
|
|
|
private ?UserPermissionGateway $userPermissionGateway = null;
|
|
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly AccessServicesFactory $accessServicesFactory,
|
|
|
|
|
private readonly SettingServicesFactory $settingServicesFactory,
|
2026-03-05 11:17:42 +01:00
|
|
|
private readonly TenantScopeService $tenantScopeService,
|
|
|
|
|
private readonly DirectoryRepositoryFactory $directoryRepositoryFactory,
|
2026-03-04 15:56:58 +01:00
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createUserSettingsGateway(): UserSettingsGateway
|
|
|
|
|
{
|
2026-03-06 00:44:52 +01:00
|
|
|
return $this->userSettingsGateway ??= new UserSettingsGateway(
|
|
|
|
|
$this->createSettingsDefaultsGateway(),
|
|
|
|
|
$this->createSettingsAppGateway(),
|
|
|
|
|
$this->createSettingsUserLifecycleGateway()
|
|
|
|
|
);
|
2026-03-04 15:56:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createUserScopeGateway(): UserScopeGateway
|
|
|
|
|
{
|
|
|
|
|
return $this->userScopeGateway ??= new UserScopeGateway($this->tenantScopeService);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createUserDirectoryGateway(): UserDirectoryGateway
|
|
|
|
|
{
|
2026-03-05 11:17:42 +01:00
|
|
|
return $this->userDirectoryGateway ??= new UserDirectoryGateway(
|
|
|
|
|
$this->directoryRepositoryFactory->createTenantRepository(),
|
|
|
|
|
$this->directoryRepositoryFactory->createRoleRepository(),
|
|
|
|
|
$this->directoryRepositoryFactory->createDepartmentRepository(),
|
|
|
|
|
);
|
2026-03-04 15:56:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createUserPermissionGateway(): UserPermissionGateway
|
|
|
|
|
{
|
|
|
|
|
return $this->userPermissionGateway ??= new UserPermissionGateway($this->createPermissionGateway());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function createPermissionGateway(): PermissionGateway
|
|
|
|
|
{
|
|
|
|
|
return $this->permissionGateway ??= $this->accessServicesFactory->createPermissionGateway();
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 00:44:52 +01:00
|
|
|
private function createSettingsDefaultsGateway(): SettingsDefaultsGateway
|
|
|
|
|
{
|
|
|
|
|
return $this->settingsDefaultsGateway ??= $this->settingServicesFactory->createSettingsDefaultsGateway();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function createSettingsAppGateway(): SettingsAppGateway
|
|
|
|
|
{
|
|
|
|
|
return $this->settingsAppGateway ??= $this->settingServicesFactory->createSettingsAppGateway();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function createSettingsUserLifecycleGateway(): SettingsUserLifecycleGateway
|
2026-03-04 15:56:58 +01:00
|
|
|
{
|
2026-03-06 00:44:52 +01:00
|
|
|
return $this->settingsUserLifecycleGateway ??= $this->settingServicesFactory->createSettingsUserLifecycleGateway();
|
2026-03-04 15:56:58 +01:00
|
|
|
}
|
|
|
|
|
}
|