Skip to content

Commit

Permalink
Make it possible to remove an authentication backend
Browse files Browse the repository at this point in the history
refs #6434
  • Loading branch information
Al2Klimov committed Jul 25, 2014
1 parent c06db74 commit 644b3a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 12 additions & 10 deletions application/controllers/ConfigController.php
Expand Up @@ -366,23 +366,25 @@ public function removeauthenticationbackendAction()

$configArray = IcingaConfig::app('authentication', true)->toArray();
$authBackend = $this->getParam('auth_backend');
if (!isset($configArray[$authBackend])) {
Notification::error('Can\'t perform removal: Unknown Authentication Backend Provided');
$this->render('authentication/remove');
return;
if (false === array_key_exists($authBackend, $configArray)) {
$this->addErrorMessage(
$this->translate('Can\'t perform removal: Unknown authentication backend provided')
);
$this->redirectNow('config/configurationerror');
}

$form = new ConfirmRemovalForm();
$form->setRequest($this->getRequest());
$form->setRemoveTarget('auth_backend', $authBackend);
$request = $this->getRequest();

if ($form->isSubmittedAndValid()) {
if ($request->isPost() && $form->isValid($request->getPost())) {
unset($configArray[$authBackend]);
if ($this->writeAuthenticationFile($configArray)) {
Notification::success('Authentication Backend "' . $authBackend . '" Removed');
$this->redirectNow("config/authentication");
Notification::success(sprintf(
$this->translate('Authentication Backend "%s" Removed'),
$authBackend
));
$this->redirectNow('config/authentication');
}
return;
}

$this->view->form = $form;
Expand Down
14 changes: 6 additions & 8 deletions application/views/scripts/config/authentication/remove.phtml
@@ -1,10 +1,8 @@
<h4>
<i class="icinga-icon-remove"></i>
Remove Backend "<?= $this->escape($this->name); ?>"
<?php printf(
$this->translate('Remove Backend "%s"'),
$this->escape($name)
); ?>
</h4>

<?php if (isset($this->messageBox)): ?>
<?= $this->messageBox->render() ?>
<?php endif ?>

<?= $this->form ?>
<?= $messageBox ?>
<?= $form ?>

0 comments on commit 644b3a1

Please sign in to comment.