diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c7d0d9cc..8e6841a1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# v1.10.10 +## 04/07/2021 + +1. [](#bugfix) + * Fixed missing `admin-preset.css` in multisite environments + * Regression: Fixed broken 2FA form [#2109](https://github.com/getgrav/grav-plugin-admin/issues/2109) + # v1.10.9 ## 04/06/2021 diff --git a/admin.php b/admin.php index 78260d25c..e58f3a238 100644 --- a/admin.php +++ b/admin.php @@ -34,7 +34,6 @@ use Grav\Plugin\Admin\AdminController; use Grav\Plugin\Admin\Twig\AdminTwigExtension; use Grav\Plugin\Admin\WhiteLabel; -use Grav\Plugin\FlexObjects\FlexFormFactory; use Grav\Plugin\Form\Form; use Grav\Plugin\Form\Forms; use Grav\Plugin\Login\Login; @@ -684,10 +683,10 @@ public function onTwigSiteVariables() $twig->twig_vars['forms'] = $forms; // preserve form validation - if (!isset($twig->twig_vars['form'])) { - if ($this->admin->form) { - $twig->twig_vars['form'] = $this->admin->form; - } elseif (isset($header->form)) { + if ($this->admin->form) { + $twig->twig_vars['form'] = $this->admin->form; + } elseif (!isset($twig->twig_vars['form'])) { + if (isset($header->form)) { $twig->twig_vars['form'] = new Form($page); } elseif (isset($header->forms)) { $twig->twig_vars['form'] = new Form($page, null, reset($header->forms)); diff --git a/blueprints.yaml b/blueprints.yaml index 25696c837..2d761acc0 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Admin Panel slug: admin type: plugin -version: 1.10.9 +version: 1.10.10 description: Adds an advanced administration panel to manage your site icon: empire author: diff --git a/classes/plugin/Controllers/Login/LoginController.php b/classes/plugin/Controllers/Login/LoginController.php index c625f3242..240a93379 100644 --- a/classes/plugin/Controllers/Login/LoginController.php +++ b/classes/plugin/Controllers/Login/LoginController.php @@ -250,21 +250,26 @@ public function taskTwofa(): ResponseInterface return $this->createRedirectResponse('/'); } + $login = $this->getLogin(); + $this->page = $this->createPage('login'); - $this->form = $this->getForm('admin-login-twofa'); + $this->form = $this->getForm('login-twofa'); try { $this->checkNonce(); } catch (PageExpiredException $e) { $this->setMessage($this->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error'); - return $this->createDisplayResponse(); + // Failed 2FA nonce check, logout and redirect. + $login->logout(['admin' => true]); + $this->form->reset(); + + return $this->createRedirectResponse('/'); } $post = $this->getPost(); $data = $post['data'] ?? []; - $login = $this->getLogin(); try { $twoFa = $login->twoFactorAuth(); } catch (TwoFactorAuthException $e) { diff --git a/themes/grav/templates/partials/login-form.html.twig b/themes/grav/templates/partials/login-form.html.twig index 8010767a9..99234030c 100755 --- a/themes/grav/templates/partials/login-form.html.twig +++ b/themes/grav/templates/partials/login-form.html.twig @@ -10,8 +10,6 @@ {% endblock %} {% block form %} - {% set form = forms['login'] %} - {% for field_name,field in form.fields %} {% if field.type %} {% set field = field|merge({ name: field.name ?? field_name }) %} diff --git a/themes/grav/templates/partials/login-twofa.html.twig b/themes/grav/templates/partials/login-twofa.html.twig index ada829f6d..7cb7892f7 100644 --- a/themes/grav/templates/partials/login-twofa.html.twig +++ b/themes/grav/templates/partials/login-twofa.html.twig @@ -5,8 +5,6 @@ {% block form %} - {% set form = forms['login-twofa'] %} - {% for field_name, field in form.fields %} {% if field.type %} {% set field = field|merge({ name: field.name ?? field_name }) %} diff --git a/themes/grav/templates/partials/stylesheets.html.twig b/themes/grav/templates/partials/stylesheets.html.twig index d684562d3..a3153c97b 100644 --- a/themes/grav/templates/partials/stylesheets.html.twig +++ b/themes/grav/templates/partials/stylesheets.html.twig @@ -1,6 +1,6 @@ {% do assets.addCss(theme_url~'/css-compiled/nucleus.css', {priority: 20}) %} {% do assets.addCss(theme_url~'/css-compiled/template.css', {priority: 20}) %} -{% do assets.addCss(base_url_frontend~'/assets/admin-preset.css', {priority: 5}) %} +{% do assets.addCss('asset://admin-preset.css', {priority: 5}) %} {% do assets.addCss(theme_url~'/css-compiled/simple-fonts.css') %} {% do assets.addCss(theme_url~'/css/fork-awesome.min.css') %} {% do assets.addCss(theme_url~'/css/chartist.min.css') %} @@ -13,4 +13,4 @@ {% endif %} {% if language_codes.rtl(grav.user.language) %} {% do assets.addCss(theme_url~'/css/rtl.css') %} -{% endif %} \ No newline at end of file +{% endif %}