diff --git a/src/Exclude/ProtectedDetailController.php b/src/Exclude/ProtectedDetailController.php
index 45d338d..d5be44a 100644
--- a/src/Exclude/ProtectedDetailController.php
+++ b/src/Exclude/ProtectedDetailController.php
@@ -42,7 +42,7 @@ public function __construct(DetailController $detailController, Config $config)
*
* @param string|int $slugOrId
*/
- public function record($slugOrId, ?string $contentTypeSlug = null, bool $requirePublished = true): Response
+ public function record($slugOrId, ?string $contentTypeSlug = null, bool $requirePublished = true, string $_locale = null): Response
{
$contentType = ContentType::factory($contentTypeSlug, $this->config->get('contenttypes'));
$this->applyAllowForGroupsGuard($contentType);
@@ -50,7 +50,7 @@ public function record($slugOrId, ?string $contentTypeSlug = null, bool $require
return $this->detailController->record($slugOrId, $contentTypeSlug, $requirePublished);
}
- public function contentByFieldValue(string $contentTypeSlug, string $field, string $value): Response
+ public function contentByFieldValue(string $contentTypeSlug, string $field, string $value, string $_locale = null): Response
{
$contentType = ContentType::factory($contentTypeSlug, $this->config->get('contenttypes'));
$this->applyAllowForGroupsGuard($contentType);
diff --git a/src/Twig/LoginFormExtension.php b/src/Twig/LoginFormExtension.php
index 302dbba..a8dd244 100644
--- a/src/Twig/LoginFormExtension.php
+++ b/src/Twig/LoginFormExtension.php
@@ -7,6 +7,7 @@
use Bolt\UsersExtension\ExtensionConfigInterface;
use Bolt\UsersExtension\ExtensionConfigTrait;
use Bolt\UsersExtension\Utils\ExtensionUtils;
+use Bolt\Version;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Twig\Extension\AbstractExtension;
@@ -64,20 +65,22 @@ public function getLoginForm(bool $withLabels = true, array $labels = []): strin
public function getUsernameField(bool $withLabel, array $labels): string
{
+ $name = $this->useOldLoginForm() ? 'username' : 'login[username]';
$text = array_key_exists('username', $labels) ? $labels['username'] : 'Username';
- $label = $withLabel ? sprintf('', $text) : '';
+ $label = $withLabel ? sprintf('', $name, $text) : '';
- $input = '';
+ $input = sprintf('', $name);
return $label . $input;
}
public function getPasswordField(bool $withLabel, array $labels): string
{
+ $name = $this->useOldLoginForm() ? 'password' : 'login[password]';
$text = array_key_exists('password', $labels) ? $labels['password'] : 'Password';
- $label = $withLabel ? sprintf('', $text) : '';
+ $label = $withLabel ? sprintf('', $name, $text) : '';
- $input = '';
+ $input = sprintf('', $name);
return $label . $input;
}
@@ -101,9 +104,10 @@ public function getSubmitButton(array $labels = []): string
public function getCsrfField(): string
{
- $token = $this->csrfTokenManager->getToken('authenticate');
+ $name = $this->useOldLoginForm() ? '_csrf_token' : 'login[_token]';
+ $token = $this->csrfTokenManager->getToken($this->useOldLoginForm() ? 'authenticate' : 'login_csrf_token');
- return sprintf('', $token);
+ return sprintf('', $name, $token);
}
public function getRedirectField(string $group = '', string $pathOrUrl = ''): string
@@ -118,4 +122,8 @@ public function getRedirectField(string $group = '', string $pathOrUrl = ''): st
return sprintf('', $pathOrUrl);
}
+
+ private function useOldLoginForm(): bool{
+ return Version::compare('4.2.2', '>=');
+ }
}