Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0b750d63c |
No files matched your search
+5
-5
@@ -5,7 +5,7 @@ namespace Ulmus\User\Entity;
|
|||||||
use Ulmus\Entity\Field\Datetime;
|
use Ulmus\Entity\Field\Datetime;
|
||||||
|
|
||||||
use Ulmus\Attribute\Property\Field;
|
use Ulmus\Attribute\Property\Field;
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
|
|
||||||
#[Field\Id(readonly: true)]
|
#[Field\Id(readonly: true)]
|
||||||
@@ -57,7 +57,7 @@ class User {
|
|||||||
|
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return "{$this->firstName} {$this->lastName}";
|
return $this->fullname();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPassword($password) : self
|
public function setPassword($password) : self
|
||||||
@@ -67,16 +67,16 @@ class User {
|
|||||||
return $this->hashPassword();
|
return $this->hashPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hashPassword(? string $password = null) : self
|
public function hashPassword() : self
|
||||||
{
|
{
|
||||||
$this->password = password_hash($password ?: $this->password, PASSWORD_DEFAULT);
|
$this->password = password_hash($this->password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verifyPassword(string $password) : bool
|
public function verifyPassword(string $password) : bool
|
||||||
{
|
{
|
||||||
return password_verify($password, $this->password);
|
return password_verify($password, $this->password );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fullname() : string
|
public function fullname() : string
|
||||||
|
|||||||
@@ -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 ( $id === null || null === ( $user = $repository->loadFromPk($id) ) ) {
|
if ( null === ( $user = $repository->loadFromPk($id) ) ) {
|
||||||
throw new \Exception("User not found.");
|
throw new \Exception("User not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +123,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user