From a24840a5332d717d2afa8516d1df0b4e4b958dd1 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 26 Aug 2016 21:27:30 -0400 Subject: Add the possibility to unlock users from the user interface --- app/Controller/UserCredentialController.php | 17 +++++++++++++++++ app/ServiceProvider/AuthenticationProvider.php | 2 +- app/Template/user_view/show.php | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/Controller/UserCredentialController.php b/app/Controller/UserCredentialController.php index 4021dc37..98fe967d 100644 --- a/app/Controller/UserCredentialController.php +++ b/app/Controller/UserCredentialController.php @@ -106,4 +106,21 @@ class UserCredentialController extends BaseController return $this->changeAuthentication($values, $errors); } + + /** + * Unlock user + */ + public function unlock() + { + $user = $this->getUser(); + $this->checkCSRFParam(); + + if ($this->userLockingModel->resetFailedLogin($user['username'])) { + $this->flash->success(t('User unlocked successfully.')); + } else { + $this->flash->failure(t('Unable to unlock the user.')); + } + + $this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user['id']))); + } } diff --git a/app/ServiceProvider/AuthenticationProvider.php b/app/ServiceProvider/AuthenticationProvider.php index 978bc05b..adff1e63 100644 --- a/app/ServiceProvider/AuthenticationProvider.php +++ b/app/ServiceProvider/AuthenticationProvider.php @@ -151,7 +151,7 @@ class AuthenticationProvider implements ServiceProviderInterface $acl->add('UserCreationController', '*', Role::APP_ADMIN); $acl->add('UserListController', '*', Role::APP_ADMIN); $acl->add('UserStatusController', '*', Role::APP_ADMIN); - $acl->add('UserCredentialController', array('changeAuthentication', 'saveAuthentication'), Role::APP_ADMIN); + $acl->add('UserCredentialController', array('changeAuthentication', 'saveAuthentication', 'unlock'), Role::APP_ADMIN); return $acl; } diff --git a/app/Template/user_view/show.php b/app/Template/user_view/show.php index fc11f8a1..2f5a73af 100644 --- a/app/Template/user_view/show.php +++ b/app/Template/user_view/show.php @@ -18,6 +18,11 @@
  • dt->datetime($user['lock_expiration_date']) ?>
  • + user->isAdmin()): ?> +
  • + url->link(t('Unlock this user'), 'UserCredentialController', 'unlock', array('user_id' => $user['id']), true) ?> +
  • + -- cgit v1.2.3