mirror of
https://github.com/Icinga/icingaweb2.git
synced 2026-06-13 02:20:30 -04:00
`TwoFactorController::configAction()` renders `TwoFactorEnrollmentForm`, which shows a method-selector dropdown (autosubmit), the method-specific fieldset contributed by `assembleEnrollmentFormElements()`, and either an "Enroll" or "Unenroll" submit button depending on current enrollment state. `AccountController`, `MyDevicesController`, and `NavigationController` each gain a "Two-Factor Auth" tab.
73 lines
2.2 KiB
PHP
73 lines
2.2 KiB
PHP
<?php
|
|
|
|
// SPDX-FileCopyrightText: 2021 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
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', [
|
|
'title' => $this->translate('Update your account'),
|
|
'label' => $this->translate('My Account'),
|
|
'url' => 'account'
|
|
])
|
|
->add('navigation', [
|
|
'title' => $this->translate('List and configure your own navigation items'),
|
|
'label' => $this->translate('Navigation'),
|
|
'url' => 'navigation'
|
|
])
|
|
->add('devices', [
|
|
'title' => $this->translate('List of devices you are logged in'),
|
|
'label' => $this->translate('My Devices'),
|
|
'url' => 'my-devices'
|
|
])
|
|
->add('two-factor', [
|
|
'title' => $this->translate('Configure two-factor authentication'),
|
|
'label' => $this->translate('Two-Factor Auth'),
|
|
'url' => 'two-factor/config'
|
|
])
|
|
->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');
|
|
}
|
|
}
|