From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- .../controllers/ManageUserDevicesController.php | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 application/controllers/ManageUserDevicesController.php (limited to 'application/controllers/ManageUserDevicesController.php') diff --git a/application/controllers/ManageUserDevicesController.php b/application/controllers/ManageUserDevicesController.php new file mode 100644 index 0000000..db054d1 --- /dev/null +++ b/application/controllers/ManageUserDevicesController.php @@ -0,0 +1,84 @@ +assertPermission('application/sessions'); + } + + public function indexAction() + { + $this->getTabs() + ->add( + 'manage-user-devices', + array( + 'title' => $this->translate('List of users who stay logged in'), + 'label' => $this->translate('Users'), + 'url' => 'manage-user-devices', + 'data-base-target' => '_self' + ) + )->activate('manage-user-devices'); + + $usersList = (new RememberMeUserList()) + ->setUsers(RememberMe::getAllUser()) + ->setUrl('manage-user-devices/devices'); + + $this->addContent($usersList); + + if (! $this->hasDb()) { + Notification::warning( + $this->translate("Users can't stay logged in without a database configuration backend") + ); + } + } + + public function devicesAction() + { + $this->getTabs() + ->add( + 'manage-devices', + array( + 'title' => $this->translate('List of devices'), + 'label' => $this->translate('Devices'), + 'url' => 'manage-user-devices/devices' + ) + )->activate('manage-devices'); + + $name = $this->params->getRequired('name'); + $data = (new RememberMeUserDevicesList()) + ->setDevicesList(RememberMe::getAllByUsername($name)) + ->setUsername($name) + ->setUrl('manage-user-devices/delete'); + + $this->addContent($data); + } + + public function deleteAction() + { + (new RememberMe())->remove($this->params->getRequired('fingerprint')); + + $this->redirectNow( + Url::fromPath('manage-user-devices/devices') + ->addParams(['name' => $this->params->getRequired('name')]) + ); + } +} -- cgit v1.2.3