Initial commit
This commit is contained in:
31
playarea/datatypes/datatype.user.php
Normal file
31
playarea/datatypes/datatype.user.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user