1
0
mirror of synced 2024-11-25 14:26:08 +03:00
service-bundle/Security/FrontApiClientAuthenticator.php

53 lines
1.1 KiB
PHP
Raw Normal View History

2021-02-05 14:47:54 +03:00
<?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;
}
}