diff --git a/src/Interfaces/Authentication/IUser.php b/src/Interfaces/Authentication/IUser.php index 363cfe8..f95824c 100644 --- a/src/Interfaces/Authentication/IUser.php +++ b/src/Interfaces/Authentication/IUser.php @@ -7,4 +7,6 @@ interface IUser const PERMISSION_ADMIN = 1; public function hasPermission(int $permission): bool; + + public function getDisplayName(): string; } diff --git a/src/Model/User.php b/src/Model/User.php index cdc34dd..0814a78 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -6,7 +6,7 @@ class User extends BaseModel implements IUser { private static array $types = ['user', 'admin']; - protected static array $fields = ['email', 'password', 'type']; + protected static array $fields = ['email', 'password', 'type', 'active']; private string $email; @@ -14,6 +14,8 @@ class User extends BaseModel implements IUser private string $type = 'user'; + private bool $active = false; + public function setEmail(string $email): void { $this->email = $email; @@ -36,6 +38,11 @@ class User extends BaseModel implements IUser } } + public function setActive($active): void + { + $this->active = (bool) $active; + } + public function getEmail(): string { return $this->email; @@ -51,6 +58,11 @@ class User extends BaseModel implements IUser return $this->type; } + public function getActive(): bool + { + return $this->active; + } + public function hasPermission(int $permission): bool { switch ($permission) { @@ -63,6 +75,11 @@ class User extends BaseModel implements IUser } } + public function getDisplayName(): string + { + return $this->email; + } + public function checkPassword(string $password): bool { return password_verify($password, $this->password); diff --git a/views/templates/header.php b/views/templates/header.php index 62db163..88d5bf9 100644 --- a/views/templates/header.php +++ b/views/templates/header.php @@ -1,8 +1,25 @@
+ user()) : ?> + + + + = Container::$request->user()->getDisplayName() ?>Logout + + Sign upLogin + +
+