Thank you for catching that. Will create another patch. On Tue Jun 3, 2025 at 11:48 AM CEST, Michael Köppl wrote: > 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.sh...@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