Skip to content

Commit

Permalink
loadUserByUsernameからloadUserByIdentifierを呼ぶように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
chihiro-adachi committed Feb 4, 2024
1 parent 8e0bd8d commit b7feb8a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
23 changes: 11 additions & 12 deletions src/Eccube/Security/Core/User/CustomerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions src/Eccube/Security/Core/User/MemberProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b7feb8a

Please sign in to comment.