From: Marcin Haba Date: Sun, 7 Nov 2021 08:36:34 +0000 (+0100) Subject: baculum: Unset default API host setting if default API host is no longer assigned... X-Git-Tag: Release-11.3.2~137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1fd582db5844ec72a1f0d485a0f1cea37c7eae8;p=thirdparty%2Fbacula.git baculum: Unset default API host setting if default API host is no longer assigned to user --- diff --git a/gui/baculum/protected/Web/Class/WebUser.php b/gui/baculum/protected/Web/Class/WebUser.php index 617147732..78e0b2fe7 100644 --- a/gui/baculum/protected/Web/Class/WebUser.php +++ b/gui/baculum/protected/Web/Class/WebUser.php @@ -265,8 +265,13 @@ class WebUser extends TUser { */ public function getDefaultAPIHost() { $def_host = $this->getState(self::DEFAULT_API_HOST); + $api_hosts = $this->getAPIHosts(); + if ($def_host && !in_array($def_host, $api_hosts)) { + // The default host is not longer assigned to user. Don't allow to use this host. + $def_host = null; + $this->setDefaultAPIHost(null); // delete default host + } if (!$def_host) { - $api_hosts = $this->getAPIHosts(); if (count($api_hosts) == 1) { // only one host assigned, so use it as default host $def_host = $api_hosts[0];