/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Authenticator
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Authenticator/FormAuthenticator.php (4766B)
'Users.reCaptcha.login',
];
/**
* Constructor
*
* @param \Authentication\Identifier\IdentifierInterface $identifier Identifier or identifiers collection.
* @param array $config Configuration settings.
*/
public function __construct(IdentifierInterface $identifier, array $config = [])
{
$this->identifier = $identifier;
$this->setConfig($config);
}
/**
* Gets the actual base authenticator
*
* @return \Authentication\Authenticator\AuthenticatorInterface
*/
public function getBaseAuthenticator()
{
if ($this->baseAuthenticator === null) {
$this->baseAuthenticator = $this->createBaseAuthenticator($this->identifier, $this->getConfig());
}
return $this->baseAuthenticator;
}
/**
* Create the base authenticator
*
* @param \Authentication\Identifier\IdentifierInterface $identifier Identifier or identifiers collection.
* @param array $config Configuration settings.
* @return \Authentication\Authenticator\AuthenticatorInterface
*/
protected function createBaseAuthenticator(IdentifierInterface $identifier, array $config = [])
{
unset($config['keyCheckEnabledRecaptcha']);
if (!isset($config['baseClassName'])) {
return new BaseFormAuthenticator($identifier, $config);
}
$className = $config['baseClassName'];
unset($config['baseClassName']);
if (!class_exists($className)) {
throw new \InvalidArgumentException(__('Base class for FormAuthenticator {0} does not exist', $className));
}
return new $className($identifier, $config);
}
/**
* Authenticates the identity contained in a request. Wrapper for Authentication\Authenticator\FormAuthenticator
* to also check reCaptcha. Will use the `config.userModel`, and `config.fields`
* to find POST data that is used to find a matching record in the `config.userModel`. Will return false if
* there is no post data, either username or password is missing, or if the scope conditions have not been met.
*
* @param \Psr\Http\Message\ServerRequestInterface $request The request that contains login information.
* @return \Authentication\Authenticator\ResultInterface
*/
public function authenticate(ServerRequestInterface $request): ResultInterface
{
$result = $this->getBaseAuthenticator()->authenticate($request);
$checkKey = $this->getConfig('keyCheckEnabledRecaptcha');
if (!Configure::read($checkKey) || in_array($result->getStatus(), [Result::FAILURE_OTHER, Result::FAILURE_CREDENTIALS_MISSING])) {
return $result;
}
if ($this->validateReCaptchaFromRequest($request)) {
return $result;
}
return new Result(null, self::FAILURE_INVALID_RECAPTCHA);
}
/**
* Call base authenticator methods
*
* @param string $name base authentication method name
* @param array $arguments used in base authenticator method
* @return mixed
*/
public function __call($name, $arguments)
{
return $this->getBaseAuthenticator()->$name(...$arguments);
}
}