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

66 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
2017-03-28 04:12:12 +00:00
namespace JKingWeb\Arsse\User\Internal;
2017-08-29 14:50:31 +00:00
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-08-29 14:50:31 +00:00
public function auth(string $user, string $password): bool {
2017-07-21 02:40:09 +00:00
try {
$hash = Arsse::$db->userPasswordGet($user);
2017-08-29 14:50:31 +00:00
} catch (Exception $e) {
2017-07-21 02:40:09 +00:00
return false;
}
2017-08-29 14:50:31 +00:00
if ($password==="" && $hash==="") {
2017-07-21 02:40:09 +00:00
return true;
}
2017-02-16 20:29:42 +00:00
return password_verify($password, $hash);
}
2017-08-29 14:50:31 +00:00
public 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
}
2017-08-29 14:50:31 +00:00
public 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-08-29 14:50:31 +00:00
public 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-08-29 14:50:31 +00:00
public 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-08-29 14:50:31 +00:00
public 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-08-29 14:50:31 +00:00
public 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-08-29 14:50:31 +00:00
public 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-08-29 14:50:31 +00:00
public 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-08-29 14:50:31 +00:00
public function userRightsSet(string $user, int $level): bool {
2017-07-21 02:40:09 +00:00
return Arsse::$db->userRightsSet($user, $level);
}
2017-08-29 14:50:31 +00:00
}