icingaweb2/application/forms/Setup/WelcomePage.php
Matthias Jentsch b5468a122d Explain token generation on the welcome page
Add token generation manual to the welcome page. Display example code
containing the current configuration dir, to generate tokens.

fixes #7408
2014-10-28 17:32:49 +01:00

53 lines
1.4 KiB
PHP

<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Setup;
use Icinga\Application\Icinga;
use Icinga\Web\Form;
use Icinga\Web\Form\Element\Note;
use Icinga\Web\Form\Validator\TokenValidator;
/**
* Wizard page to authenticate and welcome the user
*/
class WelcomePage extends Form
{
/**
* The configuration directory displayed to the user in the "generate security token" infobox
*
* @var string
*/
public $configDir = '/etc/icingaweb';
/**
* Initialize this page
*/
public function init()
{
$this->setName('setup_welcome');
$this->setViewScript('form/setup-welcome.phtml');
$this->configDir = preg_replace('_/$_', '', Icinga::app()->getConfigDir());
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement(
'text',
'token',
array(
'required' => true,
'label' => t('Setup Token'),
'description' => t(
'For security reasons, we need to check that you are permitted to execute this setup. Please provide the token from the file "setup.token".'
),
'validators' => array(new TokenValidator(Icinga::app()->getConfigDir() . '/setup.token'))
)
);
}
}