[DATABASE][TOOLS] Update local_user to return the proper PhoneNumber type

This commit is contained in:
Hugo Sales 2020-07-27 03:36:34 +00:00 committed by Hugo Sales
parent 22e292276c
commit 59eba851f7
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 7 additions and 6 deletions

View File

@ -20,7 +20,7 @@ const types = [
'serial' => 'int', 'serial' => 'int',
'text' => 'string', 'text' => 'string',
'varchar' => 'string', 'varchar' => 'string',
'phone_number' => 'PhoneNumberType', 'phone_number' => 'PhoneNumber',
]; ];
$path = Yaml::parseFile(ROOT . '/config/services.yaml')['services']['app.core.schemadef_driver']['arguments'][0]; $path = Yaml::parseFile(ROOT . '/config/services.yaml')['services']['app.core.schemadef_driver']['arguments'][0];

View File

@ -25,6 +25,7 @@ use App\Util\Common;
use DateTime; use DateTime;
use DateTimeInterface; use DateTimeInterface;
use Exception; use Exception;
use libphonenumber\PhoneNumber;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
/** /**
@ -52,7 +53,7 @@ class LocalUser implements UserInterface
private ?bool $is_email_verified; private ?bool $is_email_verified;
private ?string $language; private ?string $language;
private ?string $timezone; private ?string $timezone;
private ?PhoneNumberType $phone_number; private ?PhoneNumber $phone_number;
private ?int $sms_carrier; private ?int $sms_carrier;
private ?string $sms_email; private ?string $sms_email;
private ?string $uri; private ?string $uri;
@ -132,12 +133,12 @@ class LocalUser implements UserInterface
return $this->timezone; return $this->timezone;
} }
public function setPhoneNumber(?PhoneNumberType $phone_number): self public function setPhoneNumber(?PhoneNumber $phone_number): self
{ {
$this->phone_number = $phone_number; $this->phone_number = $phone_number;
return $this; return $this;
} }
public function getPhoneNumber(): ?PhoneNumberType public function getPhoneNumber(): ?PhoneNumber
{ {
return $this->phone_number; return $this->phone_number;
} }
@ -329,8 +330,8 @@ class LocalUser implements UserInterface
if (password_verify($new_password, $this->password)) { if (password_verify($new_password, $this->password)) {
// Update old formats // Update old formats
if (password_needs_rehash($this->password, if (password_needs_rehash($this->password,
self::algoNameToConstant(Common::config('security', 'algorithm')), self::algoNameToConstant(Common::config('security', 'algorithm')),
Common::config('security', 'options')) Common::config('security', 'options'))
) { ) {
$this->changePassword($new_password, true); $this->changePassword($new_password, true);
} }