mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-03 14:32:40 +00:00
11747c93fd
Tests have been removed as well; new tests are forthcoming
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
/** @license MIT
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
declare(strict_types=1);
|
|
namespace JKingWeb\Arsse\User\Internal;
|
|
|
|
use JKingWeb\Arsse\Arsse;
|
|
use JKingWeb\Arsse\User\Exception;
|
|
|
|
trait InternalFunctions {
|
|
protected $actor = [];
|
|
|
|
public function __construct() {
|
|
}
|
|
|
|
public function auth(string $user, string $password): bool {
|
|
try {
|
|
$hash = Arsse::$db->userPasswordGet($user);
|
|
} catch (Exception $e) {
|
|
return false;
|
|
}
|
|
if ($password==="" && $hash==="") {
|
|
return true;
|
|
}
|
|
return password_verify($password, $hash);
|
|
}
|
|
|
|
public function userExists(string $user): bool {
|
|
return Arsse::$db->userExists($user);
|
|
}
|
|
|
|
public function userAdd(string $user, string $password = null): string {
|
|
return Arsse::$db->userAdd($user, $password);
|
|
}
|
|
|
|
public function userRemove(string $user): bool {
|
|
return Arsse::$db->userRemove($user);
|
|
}
|
|
|
|
public function userList(): array {
|
|
return Arsse::$db->userList();
|
|
}
|
|
|
|
public function userPasswordSet(string $user, string $newPassword = null, string $oldPassword = null): string {
|
|
return Arsse::$db->userPasswordSet($user, $newPassword);
|
|
}
|
|
}
|