Added handling for unauthorized responses when validating an auth token.

Previously, any unsuccessful response would trigger the onValidateAuthTokenFailed callback. Now, if the response is 401 Unauthorized (indicating an invalid token), the onValidateAuthTokenFailed callback will be called. Other errors are still ignored.
This commit is contained in:
Balazs Toldi 2024-06-28 09:21:04 +02:00
parent ae125feae0
commit b68bf50359

View File

@ -116,9 +116,10 @@ public class FetchUserData {
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) {
validateAuthTokenListener.onValidateAuthTokenSuccess();
} else {
} else if (response.code() == 401) { // Unauthorized = token is invalid
validateAuthTokenListener.onValidateAuthTokenFailed();
}
// Other errors are ignored, e.g. server failure
}
@Override