fix(auth): handle 400 error during token refresh flow

This commit is contained in:
dab246
2026-02-05 15:14:19 +07:00
committed by Dat H. Pham
parent eb1805d010
commit ada44dd5d0
4 changed files with 72 additions and 16 deletions
+15 -1
View File
@@ -156,7 +156,8 @@ abstract class BaseController extends GetxController
bool validateUrgentException(dynamic exception) {
return exception is NoNetworkError
|| exception is BadCredentialsException
|| exception is ConnectionError;
|| exception is ConnectionError
|| exception is RefreshTokenFailedException;
}
void handleErrorViewState(Object error, StackTrace stackTrace) {}
@@ -177,6 +178,8 @@ abstract class BaseController extends GetxController
_handleConnectionErrorException();
} else if (exception is BadCredentialsException) {
handleBadCredentialsException();
} else if (exception is RefreshTokenFailedException) {
handleRefreshTokenFailedException();
}
}
@@ -188,6 +191,8 @@ abstract class BaseController extends GetxController
_handleConnectionErrorException();
} else if (exception is BadCredentialsException) {
handleBadCredentialsException();
} else if (exception is RefreshTokenFailedException) {
handleRefreshTokenFailedException();
}
}
@@ -242,6 +247,15 @@ abstract class BaseController extends GetxController
clearDataAndGoToLoginPage();
}
void handleRefreshTokenFailedException() {
log('$runtimeType::handleRefreshTokenFailedException:');
if (twakeAppManager.hasComposer) {
_performSaveAndReconnection();
} else {
_performReconnection();
}
}
void onDataFailureViewState(Failure failure) {
log('$runtimeType::onDataFailureViewState:failure = ${failure.runtimeType}');
if (failure is FeatureFailure) {