1
0
mirror of synced 2024-11-24 13:56:07 +03:00
service-bundle/Security/FrontApiClientAuthenticator.php
2021-02-05 14:47:54 +03:00

53 lines
1.1 KiB
PHP

<?php
namespace RetailCrm\ServiceBundle\Security;
use RetailCrm\ServiceBundle\Response\ErrorJsonResponseFactory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
/**
* Class FrontApiClientAuthenticator
*
* @package RetailCrm\ServiceBundle\Security
*/
class FrontApiClientAuthenticator extends AbstractClientAuthenticator
{
private $security;
/**
* FrontApiClientAuthenticator constructor.
*
* @param ErrorJsonResponseFactory $errorResponseFactory
* @param Security $security
*/
public function __construct(
ErrorJsonResponseFactory $errorResponseFactory,
Security $security
) {
parent::__construct($errorResponseFactory);
$this->security = $security;
}
/**
* {@inheritdoc }
*/
public function supports(Request $request): bool
{
if ($this->security->getUser()) {
return false;
}
return $request->request->has(static::AUTH_FIELD);
}
/**
* {@inheritdoc }
*/
public function supportsRememberMe(): bool
{
return true;
}
}