From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 58F1B1FF0C1 for ; Wed, 26 Aug 2026 15:42:10 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id B543E2134B; Wed, 26 Aug 2026 15:42:09 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 26 Aug 2026 15:41:59 +0200 Message-Id: Subject: Re: [PATCH login-manager v3 2/5] refactor: ui: factor out shared login tail into _finishLogin From: "Shan Shaji" To: "Azharul Haque" , X-Mailer: aerc 0.20.0 References: <20260810144713.75806-1-haque@azharul.com> <20260821034147.30194-1-haque@azharul.com> <20260821034147.30194-5-haque@azharul.com> In-Reply-To: <20260821034147.30194-5-haque@azharul.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1787751712156 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.514 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: KZKXXIC4PV7727TK2GGDFZBVCIGUBBJL X-Message-ID-Hash: KZKXXIC4PV7727TK2GGDFZBVCIGUBBJL X-MailFrom: s.shaji@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri Aug 21, 2026 at 5:41 AM CEST, Azharul Haque wrote: > Move the code that runs after an authenticated API client exists -- > handling a pending TFA challenge, fetching cluster status, persisting > the login and closing the login page -- out of _onLoginButtonPressed > into a _finishLogin method. No functional change. > > This prepares for the OpenID Connect login flow added in a following > commit, which obtains its client through a browser-based flow instead > of a password but finishes the login the same way. > > Suggested-by: Shan Shaji > Signed-off-by: Azharul Haque > --- > lib/proxmox_login_form.dart | 203 ++++++++++++++++++++---------------- > 1 file changed, 111 insertions(+), 92 deletions(-) > > diff --git a/lib/proxmox_login_form.dart b/lib/proxmox_login_form.dart > index 5b9a64e..6039407 100644 > --- a/lib/proxmox_login_form.dart > +++ b/lib/proxmox_login_form.dart > @@ -478,98 +478,13 @@ class _ProxmoxLoginPageState extends State { > var client =3D await proxclient.authenticate( > '$username@$realm', password, origin, settings.sslValidation!)= ; > > - if (client.credentials.tfa !=3D null && > - client.credentials.tfa!.kinds().isNotEmpty) { > - if (!mounted) return; > - ProxmoxApiClient? tfaclient =3D > - await Navigator.of(context).push(MaterialPageRoute( > - builder: (context) =3D> ProxmoxTfaForm( > - apiClient: client, > - ), > - )); > - > - if (tfaclient !=3D null) { > - client =3D tfaclient; > - } else { > - setState(() { > - _progressModel.inProgress -=3D 1; > - }); Updating this progress state is missing in the factored out block. Can I please know why this was removed? > - return; > - } > - } > - [snip] > + await _finishLogin( > + client, > + realm: realm!, > + username: username, > + enteredPassword: enteredPassword, > + savedPassword: savedPassword, > + ); > } on proxclient.ProxmoxApiException catch (e) { > print(e); > if (!mounted) return; > @@ -618,6 +533,110 @@ class _ProxmoxLoginPageState extends State { > }); > } > > + /// Common tail of the login flow once an authenticated client exists: > + /// handles a pending TFA challenge, fetches cluster status, persists = the > + /// login and closes the login page. Returns early (without closing th= e > + /// page) if the user cancels a TFA challenge. > + Future _finishLogin( > + ProxmoxApiClient client, { > + required String realm, > + required String username, > + String enteredPassword =3D '', > + String? savedPassword, > + }) async { > + if (client.credentials.tfa !=3D null && > + client.credentials.tfa!.kinds().isNotEmpty) { > + if (!mounted) return; > + ProxmoxApiClient? tfaclient =3D > + await Navigator.of(context).push(MaterialPageRoute( > + builder: (context) =3D> ProxmoxTfaForm( > + apiClient: client, > + ), > + )); > + > + if (tfaclient !=3D null) { > + client =3D tfaclient; > + } else { I meant here. > + return; > + } > + } > + > + final status =3D await client.getClusterStatus(); > + final hostname =3D > + status.singleWhereOrNull((element) =3D> element.local ?? false)?= .name; > + var loginStorage =3D await ProxmoxLoginStorage.fromLocalStorage(); > + [snip]