Add password feature

This commit is contained in:
Dennis Eichhorn 2017-01-22 21:04:39 +01:00
parent 695f1623b1
commit 9ccdf2a5f2

View File

@ -124,6 +124,14 @@ class Account implements ArrayableInterface, \JsonSerializable
*/ */
protected $groups = []; protected $groups = [];
/**
* Password.
*
* @var Password
* @since 1.0.0
*/
protected $password = '';
/** /**
* Account type. * Account type.
* *
@ -326,6 +334,21 @@ class Account implements ArrayableInterface, \JsonSerializable
return $this->createdAt ?? new \DateTime('NOW'); return $this->createdAt ?? new \DateTime('NOW');
} }
/**
* Generate password.
*
* @param string $password Password
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function generatePassword(string $password) /* : void */
{
$this->password = password_hash($password, PASSWORD_DEFAULT);
}
/** /**
* Set name. * Set name.
* *
@ -487,7 +510,7 @@ class Account implements ArrayableInterface, \JsonSerializable
*/ */
public function __toString() public function __toString()
{ {
return $this->jsonSerialize(); return json_encode($this->toArray());
} }
/** /**
@ -500,7 +523,7 @@ class Account implements ArrayableInterface, \JsonSerializable
*/ */
public function jsonSerialize() public function jsonSerialize()
{ {
return json_encode($this->toArray()); return $this->toArray();
} }
} }