31 lines
1.0 KiB
PHP
31 lines
1.0 KiB
PHP
<?php
|
|
|
|
class User extends Item {
|
|
public string $title = "Пользователи";
|
|
public string $description = "Управление пользователями сайта.";
|
|
public string $icon = "people";
|
|
public bool $visible_content = false;
|
|
public function __construct($item_id)
|
|
{
|
|
parent::__construct($item_id);
|
|
$this->props = array(
|
|
"username" => new Prop($this, "username", "", "Логин", true, "username"),
|
|
"reg_time" => new Prop($this, "reg_time", time(), "Дата регистрации", true, "reg_time"),
|
|
"password" => new Prop($this, "password", "", "Пароль", false, "password"),
|
|
);
|
|
}
|
|
|
|
public function check_password($password): bool
|
|
{
|
|
$hash = $this->get_prop("password");
|
|
if(password_verify($password, $hash)) return true;
|
|
return false;
|
|
}
|
|
|
|
public function set_password($password)
|
|
{
|
|
$hash = password_hash($password, PASSWORD_DEFAULT);
|
|
$this->set_prop("password", $hash);
|
|
return $hash;
|
|
}
|
|
} |