From 55cdad7d40d75d1ee401f3442091e226df13e2ce Mon Sep 17 00:00:00 2001 From: hama Date: Fri, 11 Sep 2020 13:34:25 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E5=90=8D=E3=82=92=E3=82=AB?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=9E=E3=82=A4=E3=82=BA=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Entity/Customer.php | 9 ++++++++- src/Eccube/Security/Core/User/CustomerProvider.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Eccube/Entity/Customer.php b/src/Eccube/Entity/Customer.php index 10d9d0480b6..27750f84230 100644 --- a/src/Eccube/Entity/Customer.php +++ b/src/Eccube/Entity/Customer.php @@ -310,12 +310,19 @@ public function getRoles() return ['ROLE_USER']; } + public static function getUsernameField(): string + { + return property_exists(static::class, 'usernameField') + ? static::$usernameField + : 'email'; + } + /** * {@inheritdoc} */ public function getUsername() { - return $this->email; + return $this->{static::getUsernameField()}; } /** diff --git a/src/Eccube/Security/Core/User/CustomerProvider.php b/src/Eccube/Security/Core/User/CustomerProvider.php index 1643488451f..226518f9c28 100644 --- a/src/Eccube/Security/Core/User/CustomerProvider.php +++ b/src/Eccube/Security/Core/User/CustomerProvider.php @@ -48,7 +48,7 @@ public function __construct(CustomerRepository $customerRepository) public function loadUserByUsername($username) { $Customer = $this->customerRepository->findOneBy([ - 'email' => $username, + Customer::getUsernameField() => $username, 'Status' => CustomerStatus::REGULAR, ]); From 229fa93dbe97611b5e59d3b8b15575258617f3fc Mon Sep 17 00:00:00 2001 From: hama Date: Thu, 1 Apr 2021 18:36:40 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=82=B7=E3=83=AA=E3=82=A2=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=82=BA=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Entity/Customer.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Eccube/Entity/Customer.php b/src/Eccube/Entity/Customer.php index baae4aef5d5..726ba0b4793 100644 --- a/src/Eccube/Entity/Customer.php +++ b/src/Eccube/Entity/Customer.php @@ -30,6 +30,8 @@ */ class Customer extends \Eccube\Entity\AbstractEntity implements UserInterface, \Serializable { + protected static $usernameField = 'phone_number'; + /** * @var int * @@ -318,7 +320,9 @@ public static function getUsernameField(): string } /** - * {@inheritdoc} + * Get username. + * + * @return string */ public function getUsername() { @@ -1171,7 +1175,7 @@ public function serialize() // CustomerRepository::loadUserByUsername() で Status をチェックしているため、ここでは不要 return serialize([ $this->id, - $this->email, + $this->getUsername(), $this->password, $this->salt, ]); @@ -1194,7 +1198,7 @@ public function unserialize($serialized) { list( $this->id, - $this->email, + $this->{static::getUsernameField()}, $this->password, $this->salt) = unserialize($serialized); } From cdd99600d6d4c54f56ac1e639d76e9f396cb7a08 Mon Sep 17 00:00:00 2001 From: hama Date: Fri, 2 Apr 2021 12:34:29 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E7=94=A8=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E6=B6=88=E3=81=97?= =?UTF-8?q?=E5=BF=98=E3=82=8C=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Entity/Customer.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Eccube/Entity/Customer.php b/src/Eccube/Entity/Customer.php index 726ba0b4793..e730237da47 100644 --- a/src/Eccube/Entity/Customer.php +++ b/src/Eccube/Entity/Customer.php @@ -30,8 +30,6 @@ */ class Customer extends \Eccube\Entity\AbstractEntity implements UserInterface, \Serializable { - protected static $usernameField = 'phone_number'; - /** * @var int *