Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0b750d63c | ||
|
|
c0f54ef12f |
No files matched your search
+21
-49
@@ -4,88 +4,60 @@ namespace Ulmus\User\Entity;
|
||||
|
||||
use Ulmus\Entity\Field\Datetime;
|
||||
|
||||
use Ulmus\Attribute\Property\Field;
|
||||
|
||||
class User {
|
||||
|
||||
/**
|
||||
* @Id('readonly' => true)
|
||||
*/
|
||||
#[Field\Id(readonly: true)]
|
||||
public int $id;
|
||||
|
||||
/**
|
||||
* @Field("length" => 35, "name" => "first_name")
|
||||
*/
|
||||
#[Field(length: 35, name: "first_name")]
|
||||
public ? string $firstName;
|
||||
|
||||
/**
|
||||
* @Field("length" => 35, "name" => "last_name")
|
||||
*/
|
||||
#[Field(length: 35, name: "last_name")]
|
||||
public ? string $lastName;
|
||||
|
||||
/**
|
||||
* @Field("length" => 255)
|
||||
*/
|
||||
#[Field(length: 150)]
|
||||
public string $email;
|
||||
|
||||
/**
|
||||
* @Field("length" => 150)
|
||||
*/
|
||||
#[Field(length: 150)]
|
||||
public ? string $address;
|
||||
|
||||
/**
|
||||
* @Field("length" => 15, 'name' => "zip_code")
|
||||
*/
|
||||
#[Field(length: 15, name: "zip_code")]
|
||||
public ? string $zipCode;
|
||||
|
||||
/**
|
||||
* @Field("length" => 45)
|
||||
*/
|
||||
#[Field(length: 45)]
|
||||
public ? string $province;
|
||||
|
||||
/**
|
||||
* @Field("length" => 3)
|
||||
*/
|
||||
#[Field(length: 3)]
|
||||
public ? string $country;
|
||||
|
||||
/**
|
||||
* @Field("length" => 15)
|
||||
*/
|
||||
#[Field(length: 15)]
|
||||
public ? string $phone;
|
||||
|
||||
/**
|
||||
* @Field("length" => 15)
|
||||
*/
|
||||
#[Field(length: 15)]
|
||||
public ? string $ext;
|
||||
|
||||
/**
|
||||
* @Field("length" => 15)
|
||||
*/
|
||||
#[Field(length: 15)]
|
||||
public ? string $mobile;
|
||||
|
||||
/**
|
||||
* @Field("length" => 255)
|
||||
*/
|
||||
#[Field(length: 255)]
|
||||
public ? string $username;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
#[Field]
|
||||
public string $password;
|
||||
|
||||
/**
|
||||
* @UpdatedAt('readonly' => true, 'name' => "updated_at")
|
||||
*/
|
||||
#[Field\UpdatedAt(readonly: true, name: "updated_at")]
|
||||
public ? Datetime $updatedAt;
|
||||
|
||||
/**
|
||||
* @CreatedAt('readonly' => true, 'name' => "created_at")
|
||||
*/
|
||||
#[Field\CreatedAt(readonly: true, name: "created_at")]
|
||||
public Datetime $createdAt;
|
||||
|
||||
public bool $logged = false;
|
||||
|
||||
public function __toString() : string
|
||||
{
|
||||
return "{$this->firstName} {$this->lastName}";
|
||||
return $this->fullname();
|
||||
}
|
||||
|
||||
public function setPassword($password) : self
|
||||
@@ -95,16 +67,16 @@ class User {
|
||||
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;
|
||||
}
|
||||
|
||||
public function verifyPassword(string $password) : bool
|
||||
{
|
||||
return password_verify($password, $this->password);
|
||||
return password_verify($password, $this->password );
|
||||
}
|
||||
|
||||
public function fullname() : string
|
||||
|
||||
@@ -35,8 +35,8 @@ class Authenticate {
|
||||
|
||||
public function rememberMe(\Ulmus\Repository $repository) : ? User
|
||||
{
|
||||
$logUser = function(? int $id) use ($repository) {
|
||||
if ( $id === null || null === ( $user = $repository->loadFromPk($id) ) ) {
|
||||
$logUser = function(int $id) use ($repository) {
|
||||
if ( null === ( $user = $repository->loadFromPk($id) ) ) {
|
||||
throw new \Exception("User not found.");
|
||||
}
|
||||
|
||||
@@ -123,9 +123,7 @@ class Authenticate {
|
||||
$this->cookie->delete('user.id');
|
||||
}
|
||||
|
||||
if (isset($this->user)) {
|
||||
$this->user->logged = false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user