1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 17:12:41 +00:00
Arsse/lib/User/Internal/InternalFunctions.php

60 lines
1.6 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
2017-03-28 04:12:12 +00:00
namespace JKingWeb\Arsse\User\Internal;
use JKingWeb\Arsse\Arsse;
2017-07-21 02:40:09 +00:00
use JKingWeb\Arsse\User\Exception;
trait InternalFunctions {
2017-02-16 20:29:42 +00:00
protected $actor = [];
public function __construct() {
}
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);
}
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
}
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
}
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
}
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
}
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
}
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
}
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-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);
}
}