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' ) ); } /** * My account */ public function indexAction() { $config = Config::app()->getSection('global'); $user = $this->Auth()->getUser(); if ($user->getAdditional('backend_type') === 'db') { if ($user->can('user/password-change')) { try { $userBackend = UserBackend::create($user->getAdditional('backend_name')); } catch (ConfigurationError $e) { $userBackend = null; } if ($userBackend !== null) { $changePasswordForm = new ChangePasswordForm(); $changePasswordForm ->setBackend($userBackend) ->handleRequest(); $this->view->changePasswordForm = $changePasswordForm; } } } // form to add, remove, enable & disable 2FA via TOTP if ($user->can('user/two-factor-authentication')) { if (isset($_POST['enabled_2fa'])) { Session::getSession()->set('enabled_2fa', $_POST['enabled_2fa'] == 1); } $totp = Session::getSession()->get('icingaweb_totp', null) ?? new Totp($user->getUsername()); $totpForm = (new TotpForm()) ->setPreferences($user->getPreferences()) ->setTotp($totp) ->setEnabled2FA(Session::getSession()->get('enabled_2fa', false)); if (isset($config->config_resource)) { $totpForm->setStore(PreferencesStore::create(new ConfigObject(array( 'resource' => $config->config_resource )), $user)); } $totpForm->handleRequest(); $this->view->totpForm = $totpForm; } $form = new PreferenceForm(); $form->setPreferences($user->getPreferences()); if (isset($config->config_resource)) { $form->setStore(PreferencesStore::create(new ConfigObject(array( 'resource' => $config->config_resource )), $user)); } $form->handleRequest(); $this->view->form = $form; $this->view->title = $this->translate('My Account'); $this->getTabs()->activate('account'); } }