From ad791918bcfb6708c5cc3b1c05eee53001024a58 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 21 Jul 2017 15:46:33 +0200 Subject: [PATCH] IcingaHostSelfServiceForm: fail early if template ...is not for Agents --- application/forms/IcingaHostSelfServiceForm.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/application/forms/IcingaHostSelfServiceForm.php b/application/forms/IcingaHostSelfServiceForm.php index 535b5cec..bc664a53 100644 --- a/application/forms/IcingaHostSelfServiceForm.php +++ b/application/forms/IcingaHostSelfServiceForm.php @@ -71,6 +71,13 @@ class IcingaHostSelfServiceForm extends DirectorForm throw new NotFoundError('Got invalid API key "%s"', $key); } + if ($this->template->getResolvedProperty('has_agent') !== 'y') { + throw new NotFoundError( + 'Got valid API key "%s", but template is not for Agents', + $key + ); + } + $this->removeElement('key'); return $this->template;