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