Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public void onCodeSent(String verificationId) {
@Override
public void onSuccess(FirebaseUser user) {
if (otpCallback == null) return;
logOtpVerification(true);
Toast.makeText(requireContext(), getString(R.string.connect_otp_verified) + user.getPhoneNumber(), Toast.LENGTH_SHORT).show();
user.getIdToken(false).addOnCompleteListener(task -> {
if (task.isSuccessful()) {
Expand All @@ -103,7 +102,6 @@ public void onSuccess(FirebaseUser user) {
@Override
public void onFailure(OtpErrorType errorType, @Nullable String errorMessage) {
if (otpCallback == null) return;
logOtpVerification(false);
String userMessage = switch (errorType) {
case INVALID_CREDENTIAL -> getString(R.string.personalid_incorrect_otp);
case TOO_MANY_REQUESTS -> getString(R.string.personalid_too_many_otp_attempts);
Comment on lines 103 to 107
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubham1g5 can we log the Logger.exception from here only as it may be interesting to know the TOO_MANY_REQUESTS, VERIFICATION_FAILED and default error message?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And its better to know how many user is facing TOO_MANY_REQUESTS error so that we can take actions in future accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Expand Down Expand Up @@ -134,7 +132,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
}

private void validateFirebaseIdToken(String firebaseIdToken) {

new PersonalIdApiHandler() {
@Override
protected void onSuccess(PersonalIdSessionData sessionData) {
Expand Down Expand Up @@ -281,10 +278,6 @@ private void verifyOtp() {
}
}

private void logOtpVerification(boolean success) {
FirebaseAnalyticsUtil.reportCccRecovery(success, AnalyticsParamValue.CCC_RECOVERY_METHOD_PRIMARY_OTP);
}

private void startResendTimer() {
resendTimerHandler.postDelayed(resendTimerRunnable, 100);
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/org/commcare/utils/FirebaseAuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import androidx.annotation.NonNull;

import org.javarosa.core.services.Logger;

public class FirebaseAuthService implements OtpAuthService {

private final FirebaseAuth firebaseAuth;
Expand Down Expand Up @@ -96,5 +98,8 @@ private void handleFirebaseException(Exception e) {
callback.onFailure(OtpErrorType.GENERIC_ERROR,
e != null ? e.getMessage() : "OTP verification failed");
}
if (e != null) {
Logger.exception("Firebase OTP verification error", e);
}
}
}