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:
@@ -47,6 +47,7 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
|
|||||||
Timer? _timeoutTimer;
|
Timer? _timeoutTimer;
|
||||||
int _autoRetryCount = 0;
|
int _autoRetryCount = 0;
|
||||||
static const int _maxAutoRetries = 1;
|
static const int _maxAutoRetries = 1;
|
||||||
|
bool _hasLoadedOnce = false;
|
||||||
|
|
||||||
static const _loginUrl =
|
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';
|
'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;
|
if (!mounted) return;
|
||||||
|
|
||||||
_autoRetryCount = 0;
|
_autoRetryCount = 0;
|
||||||
|
_hasLoadedOnce = true;
|
||||||
setState(() {
|
setState(() {
|
||||||
currentUrl = url;
|
currentUrl = url;
|
||||||
_initialPageLoaded = true;
|
_initialPageLoaded = true;
|
||||||
@@ -146,7 +148,7 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
|
|||||||
|
|
||||||
// Auto-retry once on first error before showing the error UI,
|
// Auto-retry once on first error before showing the error UI,
|
||||||
// to handle transient network issues on initial load.
|
// to handle transient network issues on initial load.
|
||||||
if (_autoRetryCount < _maxAutoRetries) {
|
if (!_hasLoadedOnce && _autoRetryCount < _maxAutoRetries) {
|
||||||
_autoRetryCount++;
|
_autoRetryCount++;
|
||||||
_retryLoad();
|
_retryLoad();
|
||||||
return;
|
return;
|
||||||
@@ -198,6 +200,7 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
|
|||||||
_hasFadedIn = false;
|
_hasFadedIn = false;
|
||||||
});
|
});
|
||||||
_autoRetryCount = 0;
|
_autoRetryCount = 0;
|
||||||
|
_hasLoadedOnce = false;
|
||||||
_animationController.reset();
|
_animationController.reset();
|
||||||
controller.loadRequest(Uri.parse(_loginUrl));
|
controller.loadRequest(Uri.parse(_loginUrl));
|
||||||
_startTimeoutTimer();
|
_startTimeoutTimer();
|
||||||
|
|||||||
Reference in New Issue
Block a user