diff --git a/src/Eccube/Security/Core/User/CustomerProvider.php b/src/Eccube/Security/Core/User/CustomerProvider.php index f5fcf54776f..f1b1522173a 100644 --- a/src/Eccube/Security/Core/User/CustomerProvider.php +++ b/src/Eccube/Security/Core/User/CustomerProvider.php @@ -51,16 +51,7 @@ public function __construct(CustomerRepository $customerRepository, EntityManage */ public function loadUserByUsername($username): Customer { - $Customer = $this->customerRepository->findOneBy([ - 'email' => $username, - 'Status' => CustomerStatus::REGULAR, - ]); - - if (null === $Customer) { - throw new UserNotFoundException(sprintf('Username "%s" does not exist.', $username)); - } - - return $Customer; + return $this->loadUserByIdentifier($username); } /** @@ -98,8 +89,16 @@ public function supportsClass($class) public function loadUserByIdentifier(string $identifier): UserInterface { - // FIXME deprecated - return $this->loadUserByUsername($identifier); + $Customer = $this->customerRepository->findOneBy([ + 'email' => $identifier, + 'Status' => CustomerStatus::REGULAR, + ]); + + if (null === $Customer) { + throw new UserNotFoundException(sprintf('Username "%s" does not exist.', $identifier)); + } + + return $Customer; } public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void diff --git a/src/Eccube/Security/Core/User/MemberProvider.php b/src/Eccube/Security/Core/User/MemberProvider.php index d6671982a0f..e957283bf84 100644 --- a/src/Eccube/Security/Core/User/MemberProvider.php +++ b/src/Eccube/Security/Core/User/MemberProvider.php @@ -51,13 +51,7 @@ public function __construct(MemberRepository $memberRepository, EntityManagerInt */ public function loadUserByUsername($username): Member { - $Member = $this->memberRepository->findOneBy(['login_id' => $username, 'Work' => Work::ACTIVE]); - - if (null === $Member) { - throw new UserNotFoundException(sprintf('Username "%s" does not exist.', $username)); - } - - return $Member; + return $this->loadUserByIdentifier($username); } /** @@ -95,8 +89,13 @@ public function supportsClass($class) public function loadUserByIdentifier(string $identifier): UserInterface { - // FIXME deprecated - return $this->loadUserByUsername($identifier); + $Member = $this->memberRepository->findOneBy(['login_id' => $identifier, 'Work' => Work::ACTIVE]); + + if (null === $Member) { + throw new UserNotFoundException(sprintf('Username "%s" does not exist.', $identifier)); + } + + return $Member; } public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void