2017-03-07 23:01:13 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-03-07 23:01:13 +00:00
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse\User\Internal;
|
2017-03-07 23:01:13 +00:00
|
|
|
|
2017-07-15 20:44:06 +00:00
|
|
|
final class Driver implements \JKingWeb\Arsse\User\Driver {
|
2018-10-28 17:50:57 +00:00
|
|
|
public function __construct() {
|
|
|
|
}
|
2017-03-07 23:01:13 +00:00
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public static function driverName(): string {
|
2017-07-17 11:47:57 +00:00
|
|
|
return Arsse::$lang->msg("Driver.User.Internal.Name");
|
2017-03-07 23:01:13 +00:00
|
|
|
}
|
|
|
|
|
2018-10-28 17:50:57 +00:00
|
|
|
public function auth(string $user, string $password): bool {
|
|
|
|
try {
|
|
|
|
$hash = Arsse::$db->userPasswordGet($user);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
return false;
|
2017-07-21 02:40:09 +00:00
|
|
|
}
|
2018-10-28 17:50:57 +00:00
|
|
|
if ($password==="" && $hash==="") {
|
|
|
|
return true;
|
2017-03-07 23:01:13 +00:00
|
|
|
}
|
2018-10-28 17:50:57 +00:00
|
|
|
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);
|
2017-03-07 23:01:13 +00:00
|
|
|
}
|
|
|
|
|
2018-10-28 17:50:57 +00:00
|
|
|
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);
|
|
|
|
}
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|