diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
commit | 8ca6cc32b2c789a3149861159ad258f2cb9491e3 (patch) | |
tree | 2492de6f1528dd44eaa169a5c1555026d9cb75ec /application/controllers/MyDevicesController.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-upstream.tar.xz icingaweb2-upstream.zip |
Adding upstream version 2.11.4.upstream/2.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | application/controllers/MyDevicesController.php | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/application/controllers/MyDevicesController.php b/application/controllers/MyDevicesController.php new file mode 100644 index 0000000..e0fb98a --- /dev/null +++ b/application/controllers/MyDevicesController.php @@ -0,0 +1,74 @@ +<?php +/* Icinga Web 2 | (c) 2021 Icinga GmbH | GPLv2+ */ + +namespace Icinga\Controllers; + +use Icinga\Common\Database; +use Icinga\Web\Notification; +use Icinga\Web\RememberMe; +use Icinga\Web\RememberMeUserDevicesList; +use ipl\Web\Compat\CompatController; + +/** + * MyDevicesController + * + * this controller shows you all the devices you are logged in + */ +class MyDevicesController extends CompatController +{ + use Database; + + public function init() + { + $this->getTabs() + ->add( + 'account', + array( + 'title' => $this->translate('Update your account'), + 'label' => $this->translate('My Account'), + 'url' => 'account' + ) + ) + ->add( + 'navigation', + array( + 'title' => $this->translate('List and configure your own navigation items'), + 'label' => $this->translate('Navigation'), + 'url' => 'navigation' + ) + ) + ->add( + 'devices', + array( + 'title' => $this->translate('List of devices you are logged in'), + 'label' => $this->translate('My Devices'), + 'url' => 'my-devices' + ) + )->activate('devices'); + } + + public function indexAction() + { + $name = $this->auth->getUser()->getUsername(); + + $data = (new RememberMeUserDevicesList()) + ->setDevicesList(RememberMe::getAllByUsername($name)) + ->setUsername($name) + ->setUrl('my-devices/delete'); + + $this->addContent($data); + + if (! $this->hasDb()) { + Notification::warning( + $this->translate("Users can't stay logged in without a database configuration backend") + ); + } + } + + public function deleteAction() + { + (new RememberMe())->remove($this->params->getRequired('fingerprint')); + + $this->redirectNow('my-devices'); + } +} |