diff --git a/CHANGELOG.md b/CHANGELOG.md index ea2d3bac..6fac857f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Dashboard Charts now always refresh no matter what [#753](https://github.com/getgrav/grav-plugin-admin/issues/753) * Use rawRoute for parent too when saving [#843](https://github.com/getgrav/grav-plugin-admin/issues/843) * Avoid different output when users exist or not in password recovery [#849](https://github.com/getgrav/grav/issues/849) + * Fix login to admin with permission inherited from group [#857](https://github.com/getgrav/grav-plugin-admin/issues/857) # v1.2.4 ## 10/22/2016 diff --git a/classes/admin.php b/classes/admin.php index d58980b0..0f328b5f 100644 --- a/classes/admin.php +++ b/classes/admin.php @@ -318,22 +318,29 @@ class Admin // Authenticate user. $result = $user->authenticate($data['password']); - if ($result) { - $this->user = $this->session->user = $user; - - /** @var Grav $grav */ - $grav = $this->grav; - - unset($this->grav['user']); - $this->grav['user'] = $user; - - $this->setMessage($this->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info'); - $grav->redirect($post['redirect']); + if (!$result) { + return false; } } } - return $this->authorize(); + $action = []; + + if ($user->authorize('admin.login')) { + $this->user = $this->session->user = $user; + + /** @var Grav $grav */ + $grav = $this->grav; + + unset($this->grav['user']); + $this->grav['user'] = $user; + + $this->setMessage($this->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info'); + $grav->redirect($post['redirect']); + return true; //never reached + } + + return false; } /** diff --git a/themes/grav/templates/login.html.twig b/themes/grav/templates/login.html.twig index 766613d5..e93048f1 100644 --- a/themes/grav/templates/login.html.twig +++ b/themes/grav/templates/login.html.twig @@ -1,27 +1,38 @@ {% embed 'partials/login.html.twig' with {title:'Grav Admin Login'} %} {% block form %} - {% for field in page.header.form.fields %} - {% if field.type %} -