5 Commits
2 changed files with 7 additions and 5 deletions

No files matched your search

+3 -3
View File
@@ -57,7 +57,7 @@ class User {
public function __toString() : string public function __toString() : string
{ {
return $this->fullname(); return "{$this->firstName} {$this->lastName}";
} }
public function setPassword($password) : self public function setPassword($password) : self
@@ -67,9 +67,9 @@ class User {
return $this->hashPassword(); return $this->hashPassword();
} }
public function hashPassword() : self public function hashPassword(? string $password = null) : self
{ {
$this->password = password_hash($this->password, PASSWORD_DEFAULT); $this->password = password_hash($password ?: $this->password, PASSWORD_DEFAULT);
return $this; return $this;
} }
+4 -2
View File
@@ -35,8 +35,8 @@ class Authenticate {
public function rememberMe(\Ulmus\Repository $repository) : ? User public function rememberMe(\Ulmus\Repository $repository) : ? User
{ {
$logUser = function(int $id) use ($repository) { $logUser = function(? int $id) use ($repository) {
if ( null === ( $user = $repository->loadFromPk($id) ) ) { if ( $id === null || null === ( $user = $repository->loadFromPk($id) ) ) {
throw new \Exception("User not found."); throw new \Exception("User not found.");
} }
@@ -123,7 +123,9 @@ class Authenticate {
$this->cookie->delete('user.id'); $this->cookie->delete('user.id');
} }
if (isset($this->user)) {
$this->user->logged = false; $this->user->logged = false;
}
return $this; return $this;
} }