From a5985cdac9f2bcfdfa8152723c157ff552ff9da5 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sun, 7 Nov 2021 09:36:34 +0100 Subject: [PATCH] baculum: Unset default API host setting if default API host is no longer assigned to user --- gui/baculum/protected/Web/Class/WebUser.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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]; -- 2.47.3