]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Unset default API host setting if default API host is no longer assigned...
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 7 Nov 2021 08:36:34 +0000 (09:36 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:27 +0000 (09:03 +0100)
gui/baculum/protected/Web/Class/WebUser.php

index 617147732089f320786a1a6e0b81c0cd0c8fb614..78e0b2fe7782f6d33666248a29cee6f7357db8e9 100644 (file)
@@ -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];