From 9ccdf2a5f2313dd84f7a9e6156f7ebf86cfe47e6 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 22 Jan 2017 21:04:39 +0100 Subject: [PATCH] Add password feature --- Account/Account.php | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Account/Account.php b/Account/Account.php index 4c4690077..1c3769240 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -124,6 +124,14 @@ class Account implements ArrayableInterface, \JsonSerializable */ protected $groups = []; + /** + * Password. + * + * @var Password + * @since 1.0.0 + */ + protected $password = ''; + /** * Account type. * @@ -326,6 +334,21 @@ class Account implements ArrayableInterface, \JsonSerializable return $this->createdAt ?? new \DateTime('NOW'); } + /** + * Generate password. + * + * @param string $password Password + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function generatePassword(string $password) /* : void */ + { + $this->password = password_hash($password, PASSWORD_DEFAULT); + } + /** * Set name. * @@ -487,7 +510,7 @@ class Account implements ArrayableInterface, \JsonSerializable */ public function __toString() { - return $this->jsonSerialize(); + return json_encode($this->toArray()); } /** @@ -500,7 +523,7 @@ class Account implements ArrayableInterface, \JsonSerializable */ public function jsonSerialize() { - return json_encode($this->toArray()); + return $this->toArray(); } }