Add the possibility to unlock users from the user interface
This commit is contained in:
@@ -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'])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
<li><?= t('Number of failed login:') ?> <strong><?= $user['nb_failed_login'] ?></strong></li>
|
||||
<?php if ($user['lock_expiration_date'] != 0): ?>
|
||||
<li><?= t('Account locked until:') ?> <strong><?= $this->dt->datetime($user['lock_expiration_date']) ?></strong></li>
|
||||
<?php if ($this->user->isAdmin()): ?>
|
||||
<li>
|
||||
<?= $this->url->link(t('Unlock this user'), 'UserCredentialController', 'unlock', array('user_id' => $user['id']), true) ?>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</ul>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user