- WIP on authentication portal

This commit is contained in:
mcndave committed 2023-11-03 19:44:46 -04:00
1 parent 1559ceb248
commit 7769b1a1ca
15 files changed
+220 -134

No files matched your search

+15 -9
View File
@@ -2,11 +2,12 @@
namespace Ulmus\User\Entity;
use Ulmus\Entity\EntityInterface;
use Ulmus\Entity\Field\Datetime;
use Ulmus\Attribute\Property\Field;
class User {
abstract class User implements UserInterface {
#[Field\Id(readonly: true)]
public int $id;
@@ -47,27 +48,27 @@ class User {
#[Field]
public string $password;
#[Field\UpdatedAt(name: "updated_at")]
public readonly ? Datetime $updatedAt;
#[Field\UpdatedAt(name: "updated_at", readonly: true)]
public ? Datetime $updatedAt;
#[Field\CreatedAt(name: "created_at")]
public readonly Datetime $createdAt;
#[Field\CreatedAt(name: "created_at", readonly: true)]
public Datetime $createdAt;
public bool $logged = false;
public function __toString() : string
{
return "{$this->firstName} {$this->lastName}";
return $this->fullName();
}
public function setPassword($password) : self
public function setPassword($password) : static
{
$this->password = $password;
return $this->hashPassword();
}
public function hashPassword(? string $password = null) : self
public function hashPassword(? string $password = null) : static
{
$this->password = password_hash($password ?: $this->password, PASSWORD_DEFAULT);
@@ -79,8 +80,13 @@ class User {
return password_verify($password, $this->password);
}
public function fullname() : string
public function fullName() : string
{
return trim( ( $this->firstName ?? "" ) . " " . ( $this->lastName ?? "" ) );
}
public function loggedIn(): bool
{
return $this->logged;
}
}