1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00
Arsse/lib/User/Internal/InternalFunctions.php
J. King f902346b6c Eliminated passing of RuntimeData instances
- RuntimeData has now been replaced by a single static Data class
- The Data class has a load() method which fills the same role as the constructor of RuntimeData
- The static Lang class is now an instantiable class and is a member of Data
- All tests have been adjusted and pass
- The Exception tests no longer require convoluted workarounds: a simple mock  for Data::$l suffices; Lang tests also use a mock to prevent loops now instead of using a workaround
2017-03-28 18:50:00 -04:00

55 lines
No EOL
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace JKingWeb\Arsse\User\Internal;
use JKingWeb\Arsse\Data;
trait InternalFunctions {
protected $actor = [];
public function __construct() {
$this->db = Data::$db;
}
function auth(string $user, string $password): bool {
if(!Data::$user->exists($user)) return false;
$hash = $this->db->userPasswordGet($user);
if($password==="" && $hash==="") return true;
return password_verify($password, $hash);
}
function userExists(string $user): bool {
return $this->db->userExists($user);
}
function userAdd(string $user, string $password = null): string {
return $this->db->userAdd($user, $password);
}
function userRemove(string $user): bool {
return $this->db->userRemove($user);
}
function userList(string $domain = null): array {
return $this->db->userList($domain);
}
function userPasswordSet(string $user, string $newPassword = null, string $oldPassword = null): string {
return $this->db->userPasswordSet($user, $newPassword);
}
function userPropertiesGet(string $user): array {
return $this->db->userPropertiesGet($user);
}
function userPropertiesSet(string $user, array $properties): array {
return $this->db->userPropertiesSet($user, $properties);
}
function userRightsGet(string $user): int {
return $this->db->userRightsGet($user);
}
function userRightsSet(string $user, int $level): bool {
return $this->db->userRightsSet($user, $level);
}
}