mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 09:02:41 +00:00
11b2066922
Includes PHPDoc license tag in the file-level block with accompanying copyright notice. Also added an AUTHORS file on the off chance of outside contributions
56 lines
1.7 KiB
PHP
56 lines
1.7 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\Test\User;
|
|
|
|
use JKingWeb\Arsse\User\Driver;
|
|
|
|
class DriverInternalMock extends Database implements Driver {
|
|
public $db = [];
|
|
protected $functions = [
|
|
"auth" => Driver::FUNC_INTERNAL,
|
|
"userList" => Driver::FUNC_INTERNAL,
|
|
"userExists" => Driver::FUNC_INTERNAL,
|
|
"userAdd" => Driver::FUNC_INTERNAL,
|
|
"userRemove" => Driver::FUNC_INTERNAL,
|
|
"userPasswordSet" => Driver::FUNC_INTERNAL,
|
|
"userPropertiesGet" => Driver::FUNC_INTERNAL,
|
|
"userPropertiesSet" => Driver::FUNC_INTERNAL,
|
|
"userRightsGet" => Driver::FUNC_INTERNAL,
|
|
"userRightsSet" => Driver::FUNC_INTERNAL,
|
|
];
|
|
|
|
public static function driverName(): string {
|
|
return "Mock Internal Driver";
|
|
}
|
|
|
|
public function driverFunctions(string $function = null) {
|
|
if ($function===null) {
|
|
return $this->functions;
|
|
}
|
|
if (array_key_exists($function, $this->functions)) {
|
|
return $this->functions[$function];
|
|
} else {
|
|
return Driver::FUNC_NOT_IMPLEMENTED;
|
|
}
|
|
}
|
|
|
|
public function __construct() {
|
|
}
|
|
|
|
public function auth(string $user, string $password): bool {
|
|
if (!$this->userExists($user)) {
|
|
return false;
|
|
}
|
|
if ($password==="" && $this->db[$user]['password']==="") {
|
|
return true;
|
|
}
|
|
if (password_verify($password, $this->db[$user]['password'])) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|