solve looping of dio request due to auth interceptor onError handling
This commit is contained in:
@@ -33,7 +33,14 @@ class AuthInterceptor extends Interceptor {
|
||||
ErrorInterceptorHandler handler,
|
||||
) async {
|
||||
// Handle 401 errors by refreshing token and retrying
|
||||
if (err.response?.statusCode == 401) {
|
||||
final response = err.response;
|
||||
if (response?.statusCode == 401) {
|
||||
final data = response?.data;
|
||||
// Only refresh token if error is NOT INCORRECT_TPIN (or similar business error)
|
||||
if (data is Map && data['error'] == 'INCORRECT_TPIN') {
|
||||
// Pass the error through, do not retry
|
||||
return handler.next(err);
|
||||
}
|
||||
// On 401, try to get a new token
|
||||
final token = await _authRepository.getAccessToken();
|
||||
|
||||
|
Reference in New Issue
Block a user