From b33a6d2ca0f51aa93291fc36f041a16446ec6d33 Mon Sep 17 00:00:00 2001 From: b3ni15 Date: Sun, 15 Mar 2026 18:51:36 +0000 Subject: [PATCH] Guard auto-retry to initial load only in KretenLoginWidget After the login page first loaded successfully, any subsequent navigation error (e.g. during credential entry) would silently reload _loginUrl, discarding user-entered credentials. This was because the auto-retry block only checked _autoRetryCount, which was reset to 0 by onPageFinished after every successful load. Add _hasLoadedOnce that is set true in onPageFinished and only cleared in _retry() (explicit user action). Gate the silent auto-retry on !_hasLoadedOnce so it only fires before the login page has been shown to the user for the first time. https://claude.ai/code/session_016dhktF2DaoTQeifUaZrxbP --- refilc_mobile_ui/lib/screens/login/kreten_login.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/refilc_mobile_ui/lib/screens/login/kreten_login.dart b/refilc_mobile_ui/lib/screens/login/kreten_login.dart index 35a420cf..b37be39f 100644 --- a/refilc_mobile_ui/lib/screens/login/kreten_login.dart +++ b/refilc_mobile_ui/lib/screens/login/kreten_login.dart @@ -47,6 +47,7 @@ class _KretenLoginWidgetState extends State Timer? _timeoutTimer; int _autoRetryCount = 0; static const int _maxAutoRetries = 1; + bool _hasLoadedOnce = false; static const _loginUrl = 'https://idp.e-kreta.hu/connect/authorize?prompt=login&nonce=wylCrqT4oN6PPgQn2yQB0euKei9nJeZ6_ffJ-VpSKZU&response_type=code&code_challenge_method=S256&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&code_challenge=HByZRRnPGb-Ko_wTI7ibIba1HQ6lor0ws4bcgReuYSQ&redirect_uri=https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect&client_id=kreta-ellenorzo-student-mobile-ios&state=refilc_student_mobile'; @@ -127,6 +128,7 @@ class _KretenLoginWidgetState extends State if (!mounted) return; _autoRetryCount = 0; + _hasLoadedOnce = true; setState(() { currentUrl = url; _initialPageLoaded = true; @@ -146,7 +148,7 @@ class _KretenLoginWidgetState extends State // Auto-retry once on first error before showing the error UI, // to handle transient network issues on initial load. - if (_autoRetryCount < _maxAutoRetries) { + if (!_hasLoadedOnce && _autoRetryCount < _maxAutoRetries) { _autoRetryCount++; _retryLoad(); return; @@ -198,6 +200,7 @@ class _KretenLoginWidgetState extends State _hasFadedIn = false; }); _autoRetryCount = 0; + _hasLoadedOnce = false; _animationController.reset(); controller.loadRequest(Uri.parse(_loginUrl)); _startTimeoutTimer();