Improved error message when search requires auth
This commit is contained in:
parent
287c3c1cb3
commit
e85293f338
1 changed files with 19 additions and 8 deletions
|
@ -4,10 +4,14 @@ namespace Szurubooru\SearchServices\Parsers;
|
||||||
class PostSearchParser extends AbstractSearchParser
|
class PostSearchParser extends AbstractSearchParser
|
||||||
{
|
{
|
||||||
private $authService;
|
private $authService;
|
||||||
|
private $privilegeService;
|
||||||
|
|
||||||
public function __construct(\Szurubooru\Services\AuthService $authService)
|
public function __construct(
|
||||||
|
\Szurubooru\Services\AuthService $authService,
|
||||||
|
\Szurubooru\Services\PrivilegeService $privilegeService)
|
||||||
{
|
{
|
||||||
$this->authService = $authService;
|
$this->authService = $authService;
|
||||||
|
$this->privilegeService = $privilegeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createFilter()
|
protected function createFilter()
|
||||||
|
@ -62,14 +66,21 @@ class PostSearchParser extends AbstractSearchParser
|
||||||
elseif ($token->getKey() === 'comment')
|
elseif ($token->getKey() === 'comment')
|
||||||
$this->addCommentRequirement($filter, $token);
|
$this->addCommentRequirement($filter, $token);
|
||||||
|
|
||||||
elseif ($token->getKey() === 'special' and $token->getValue() === 'liked' and $this->authService->isLoggedIn())
|
elseif ($token->getKey() === 'special' and $token->getValue() === 'liked')
|
||||||
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), 1, $token->isNegated());
|
|
||||||
|
|
||||||
elseif ($token->getKey() === 'special' and $token->getValue() === 'disliked' and $this->authService->isLoggedIn())
|
|
||||||
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), -1, $token->isNegated());
|
|
||||||
|
|
||||||
elseif ($token->getKey() === 'special' and $token->getValue() === 'fav' and $this->authService->isLoggedIn())
|
|
||||||
{
|
{
|
||||||
|
$this->privilegeService->assertLoggedIn();
|
||||||
|
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), 1, $token->isNegated());
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($token->getKey() === 'special' and $token->getValue() === 'disliked')
|
||||||
|
{
|
||||||
|
$this->privilegeService->assertLoggedIn();
|
||||||
|
$this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), -1, $token->isNegated());
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($token->getKey() === 'special' and $token->getValue() === 'fav')
|
||||||
|
{
|
||||||
|
$this->privilegeService->assertLoggedIn();
|
||||||
$token = new \Szurubooru\SearchServices\Tokens\NamedSearchToken();
|
$token = new \Szurubooru\SearchServices\Tokens\NamedSearchToken();
|
||||||
$token->setKey('fav');
|
$token->setKey('fav');
|
||||||
$token->setValue($this->authService->getLoggedInUser()->getName());
|
$token->setValue($this->authService->getLoggedInUser()->getName());
|
||||||
|
|
Loading…
Reference in a new issue