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.

Add `isDefaultRealm` boolean check to find the default realm.
Also the user's selection will have priority if a realm is
already saved.

Signed-off-by: Shan Shaji <s.sh...@proxmox.com>
---

changes since v2:
* removed "this commit" string from commit message.
* fixed `StateError` in `singleWhere` function which can happen
  when both conditions are true.
* if a realm is already saved then that realm will have priority
  over default realm. 

lib/proxmox_login_form.dart | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/proxmox_login_form.dart b/lib/proxmox_login_form.dart
index 5916563..7728594 100644
--- a/lib/proxmox_login_form.dart
+++ b/lib/proxmox_login_form.dart
@@ -697,7 +697,9 @@ 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) => widget.userModel?.realm != null
+          ? e!.realm == widget.userModel?.realm
+          : e?.isDefaultRealm == true,
       orElse: () => response?.first,
     );
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to