forked from wallabag/wallabag
Make AuthenticatorProvider use Symfony HTTP Client
This commit is contained in:
@ -10,6 +10,13 @@ use Wallabag\ExpressionLanguage\AuthenticatorProvider;
|
||||
|
||||
class LoginFormAuthenticator
|
||||
{
|
||||
private AuthenticatorProvider $authenticatorProvider;
|
||||
|
||||
public function __construct(AuthenticatorProvider $authenticatorProvider)
|
||||
{
|
||||
$this->authenticatorProvider = $authenticatorProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the configured user on the given Guzzle client.
|
||||
*
|
||||
@ -20,7 +27,7 @@ class LoginFormAuthenticator
|
||||
$postFields = [
|
||||
$siteConfig->getUsernameField() => $siteConfig->getUsername(),
|
||||
$siteConfig->getPasswordField() => $siteConfig->getPassword(),
|
||||
] + $this->getExtraFields($siteConfig, $guzzle);
|
||||
] + $this->getExtraFields($siteConfig);
|
||||
|
||||
$guzzle->post(
|
||||
$siteConfig->getLoginUri(),
|
||||
@ -77,13 +84,13 @@ class LoginFormAuthenticator
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getExtraFields(SiteConfig $siteConfig, ClientInterface $guzzle)
|
||||
private function getExtraFields(SiteConfig $siteConfig)
|
||||
{
|
||||
$extraFields = [];
|
||||
|
||||
foreach ($siteConfig->getExtraFields() as $fieldName => $fieldValue) {
|
||||
if ('@=' === substr($fieldValue, 0, 2)) {
|
||||
$expressionLanguage = $this->getExpressionLanguage($guzzle);
|
||||
$expressionLanguage = $this->getExpressionLanguage();
|
||||
$fieldValue = $expressionLanguage->evaluate(
|
||||
substr($fieldValue, 2),
|
||||
[
|
||||
@ -101,11 +108,11 @@ class LoginFormAuthenticator
|
||||
/**
|
||||
* @return ExpressionLanguage
|
||||
*/
|
||||
private function getExpressionLanguage(ClientInterface $guzzle)
|
||||
private function getExpressionLanguage()
|
||||
{
|
||||
return new ExpressionLanguage(
|
||||
null,
|
||||
[new AuthenticatorProvider($guzzle)]
|
||||
[$this->authenticatorProvider]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user