mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-03 14:32:40 +00:00
Move some Miniflux features to abstract handler
This commit is contained in:
parent
b7ce6f5c79
commit
f33359f3e3
2 changed files with 10 additions and 10 deletions
|
@ -6,6 +6,7 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
namespace JKingWeb\Arsse\REST;
|
namespace JKingWeb\Arsse\REST;
|
||||||
|
|
||||||
|
use JKingWeb\Arsse\Arsse;
|
||||||
use JKingWeb\Arsse\Misc\Date;
|
use JKingWeb\Arsse\Misc\Date;
|
||||||
use JKingWeb\Arsse\Misc\ValueInfo;
|
use JKingWeb\Arsse\Misc\ValueInfo;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
@ -15,6 +16,15 @@ abstract class AbstractHandler implements Handler {
|
||||||
abstract public function __construct();
|
abstract public function __construct();
|
||||||
abstract public function dispatch(ServerRequestInterface $req): ResponseInterface;
|
abstract public function dispatch(ServerRequestInterface $req): ResponseInterface;
|
||||||
|
|
||||||
|
/** @codeCoverageIgnore */
|
||||||
|
protected function now(): \DateTimeImmutable {
|
||||||
|
return Date::normalize("now");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isAdmin(): bool {
|
||||||
|
return (bool) Arsse::$user->propertiesGet(Arsse::$user->id, false)['admin'];
|
||||||
|
}
|
||||||
|
|
||||||
protected function fieldMapNames(array $data, array $map): array {
|
protected function fieldMapNames(array $data, array $map): array {
|
||||||
$out = [];
|
$out = [];
|
||||||
foreach ($map as $to => $from) {
|
foreach ($map as $to => $from) {
|
||||||
|
|
|
@ -116,11 +116,6 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @codeCoverageIgnore */
|
|
||||||
protected function now(): \DateTimeImmutable {
|
|
||||||
return Date::normalize("now");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function authenticate(ServerRequestInterface $req): bool {
|
protected function authenticate(ServerRequestInterface $req): bool {
|
||||||
// first check any tokens; this is what Miniflux does
|
// first check any tokens; this is what Miniflux does
|
||||||
if ($req->hasHeader("X-Auth-Token")) {
|
if ($req->hasHeader("X-Auth-Token")) {
|
||||||
|
@ -143,11 +138,6 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function isAdmin(): bool {
|
|
||||||
return (bool) Arsse::$user->propertiesGet(Arsse::$user->id, false)['admin'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function dispatch(ServerRequestInterface $req): ResponseInterface {
|
public function dispatch(ServerRequestInterface $req): ResponseInterface {
|
||||||
// try to authenticate
|
// try to authenticate
|
||||||
if (!$this->authenticate($req)) {
|
if (!$this->authenticate($req)) {
|
||||||
|
|
Loading…
Reference in a new issue