From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 3386A1FF15E for <inbox@lore.proxmox.com>; Tue, 3 Jun 2025 11:49:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 98B3615A04; Tue, 3 Jun 2025 11:49:24 +0200 (CEST) Message-ID: <88c1c2e6-3b9d-4afc-9f6d-0604befb1524@proxmox.com> Date: Tue, 3 Jun 2025 11:48:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>, Shan Shaji <s.shaji@proxmox.com> References: <20250526154137.116322-1-s.shaji@proxmox.com> <20250526154137.116322-3-s.shaji@proxmox.com> From: =?UTF-8?Q?Michael_K=C3=B6ppl?= <m.koeppl@proxmox.com> Content-Language: en-US In-Reply-To: <20250526154137.116322-3-s.shaji@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.018 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH proxmox_login_manager v2 2/2] fix #6409: add `isDefaultRealm` check to pre-select realm in login form X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> On 5/26/25 17:41, Shan Shaji wrote: > When the `default` property was selected inside the realm of the web > UI, the app's login page was not showing the default realm instead, > it was always showing PAM. > > This commit adds the `isDefaultRealm` boolean check to find the > default realm. nit: commit message should not say "This commit..." > > Signed-off-by: Shan Shaji <s.shaji@proxmox.com> > --- > > changes since v1: > * generated the patch again by comparing with master > > lib/proxmox_login_form.dart | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/proxmox_login_form.dart b/lib/proxmox_login_form.dart > index 5916563..4ed495d 100644 > --- a/lib/proxmox_login_form.dart > +++ b/lib/proxmox_login_form.dart > @@ -697,7 +697,7 @@ class _ProxmoxLoginPageState extends State<ProxmoxLoginPage> { > response?.sort((a, b) => a!.realm.compareTo(b!.realm)); > > final selection = response?.singleWhere( > - (e) => e!.realm == widget.userModel?.realm, > + (e) => e!.realm == widget.userModel?.realm || e.isDefaultRealm, This change will make the singleWhere throw a StateError "too many elements" if the user was already signed in on an instance with a realm different from the default realm and tries to connect to their PVE host again. singleWhere expects a single element to fulfill the condition. If multiple do it, it causes an exception. In this case, one realm would match the user's selected realm and another would match the default realm. To make it more clear what I mean: - Sign into a PVE host using PAM - Change the default realm to "PVE" in the web UI - Sign out from the PVE host in the app (do not delete the site) - Try to sign in again. Progress spinner with "Connecting..." since the exception is uncaught. I think the logic for this would have to be more along the lines of: final selection = response?.singleWhere( (e) { if (widget.userModel?.realm != null) { return e!.realm == widget.userModel?.realm; } else { return e!.isDefaultRealm; } }, orElse: () => response?.first, ); This gives priority to the user's selection if there is one. > orElse: () => response?.first, > ); > _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel