2016-10-28 12:27:35 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse\User\Internal;
|
2017-07-17 11:47:57 +00:00
|
|
|
use JKingWeb\Arsse\Arsse;
|
2017-07-21 02:40:09 +00:00
|
|
|
use JKingWeb\Arsse\User\Exception;
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-04-07 01:41:21 +00:00
|
|
|
trait InternalFunctions {
|
2017-02-16 20:29:42 +00:00
|
|
|
protected $actor = [];
|
2017-02-18 00:22:50 +00:00
|
|
|
|
2017-03-28 22:50:00 +00:00
|
|
|
public function __construct() {
|
2017-02-18 00:22:50 +00:00
|
|
|
}
|
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function auth(string $user, string $password): bool {
|
2017-07-21 02:40:09 +00:00
|
|
|
try {
|
|
|
|
$hash = Arsse::$db->userPasswordGet($user);
|
|
|
|
} catch(Exception $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
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 {
|
2017-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userExists($user);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
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-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userAdd($user, $password);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userRemove(string $user): bool {
|
2017-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userRemove($user);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userList(string $domain = null): array {
|
2017-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userList($domain);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2017-04-07 01:41:21 +00:00
|
|
|
|
2017-03-03 01:47:00 +00:00
|
|
|
function userPasswordSet(string $user, string $newPassword = null, string $oldPassword = null): string {
|
2017-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userPasswordSet($user, $newPassword);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userPropertiesGet(string $user): array {
|
2017-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userPropertiesGet($user);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userPropertiesSet(string $user, array $properties): array {
|
2017-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userPropertiesSet($user, $properties);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2016-11-04 02:54:27 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userRightsGet(string $user): int {
|
2017-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userRightsGet($user);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2017-04-07 01:41:21 +00:00
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function userRightsSet(string $user, int $level): bool {
|
2017-07-21 02:40:09 +00:00
|
|
|
return Arsse::$db->userRightsSet($user, $level);
|
2017-04-07 01:41:21 +00:00
|
|
|
}
|
2016-10-28 12:27:35 +00:00
|
|
|
}
|