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
This commit is contained in:
2026-03-15 18:51:36 +00:00
parent c3b1e783b8
commit b33a6d2ca0

View File

@@ -47,6 +47,7 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
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<KretenLoginWidget>
if (!mounted) return;
_autoRetryCount = 0;
_hasLoadedOnce = true;
setState(() {
currentUrl = url;
_initialPageLoaded = true;
@@ -146,7 +148,7 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
// 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<KretenLoginWidget>
_hasFadedIn = false;
});
_autoRetryCount = 0;
_hasLoadedOnce = false;
_animationController.reset();
controller.loadRequest(Uri.parse(_loginUrl));
_startTimeoutTimer();