2016-10-28 12:27:35 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\NewsSync\User;
|
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
trait InternalFunctions {
|
|
|
|
protected $actor = [];
|
2017-02-18 00:22:50 +00:00
|
|
|
|
|
|
|
public function __construct(\JKingWeb\NewsSync\RuntimeData $data) {
|
|
|
|
$this->data = $data;
|
|
|
|
$this->db = $this->data->db;
|
|
|
|
}
|
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function auth(string $user, string $password): bool {
|
|
|
|
if(!$this->data->user->exists($user)) return false;
|
|
|
|
$hash = $this->db->userPasswordGet($user);
|
2017-03-03 01:47:00 +00:00
|
|
|
if($password==="" && $hash==="") return true;
|
2017-02-16 20:29:42 +00:00
|
|
|
return password_verify($password, $hash);
|
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userExists(string $user): bool {
|
|
|
|
return $this->db->userExists($user);
|
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-20 22:04:13 +00:00
|
|
|
function userAdd(string $user, string $password = null): string {
|
2017-02-16 20:29:42 +00:00
|
|
|
return $this->db->userAdd($user, $password);
|
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userRemove(string $user): bool {
|
|
|
|
return $this->db->userRemove($user);
|
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userList(string $domain = null): array {
|
|
|
|
return $this->db->userList($domain);
|
|
|
|
}
|
|
|
|
|
2017-03-03 01:47:00 +00:00
|
|
|
function userPasswordSet(string $user, string $newPassword = null, string $oldPassword = null): string {
|
2017-02-16 20:29:42 +00:00
|
|
|
return $this->db->userPasswordSet($user, $newPassword);
|
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userPropertiesGet(string $user): array {
|
|
|
|
return $this->db->userPropertiesGet($user);
|
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userPropertiesSet(string $user, array $properties): array {
|
|
|
|
return $this->db->userPropertiesSet($user, $properties);
|
|
|
|
}
|
2016-11-04 02:54:27 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userRightsGet(string $user): int {
|
|
|
|
return $this->db->userRightsGet($user);
|
|
|
|
}
|
|
|
|
|
|
|
|
function userRightsSet(string $user, int $level): bool {
|
|
|
|
return $this->db->userRightsSet($user, $level);
|
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
}
|