Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix android phone authentication #308

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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 @@ -91,9 +91,6 @@ actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthPr

override fun onCodeSent(verificationId: String, forceResending: PhoneAuthProvider.ForceResendingToken) {
verificationProvider.codeSent { android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, this, forceResending) }
}

override fun onCodeAutoRetrievalTimeOut(verificationId: String) {
launch {
val code = verificationProvider.getVerificationCode()
try {
Expand All @@ -104,6 +101,9 @@ actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthPr
}
}

override fun onCodeAutoRetrievalTimeOut(verificationId: String) {
}
Copy link
Member

Choose a reason for hiding this comment

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

we'll need to fail the CompletableDeferred here too otherwise it will hang?

Copy link
Author

@CharlesEtieve CharlesEtieve Aug 7, 2022

Choose a reason for hiding this comment

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

I do not think we should make a response.complete() in onCodeAutoRetrievalTimeOut(), because the response can be completed only once and we would not be able to make response.complete() after user input when onCodeAutoRetrievalTimeOut() is called before.
Maybe we could add a function inside PhoneVerificationProvider: onCodeAutoRetrievalTimeOut()?

Copy link
Member

Choose a reason for hiding this comment

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

you don't want to complete, you fail it with the appropriate exception


override fun onVerificationCompleted(credential: com.google.firebase.auth.PhoneAuthCredential) {
response.complete(Result.success(AuthCredential(credential)))
Copy link
Member

Choose a reason for hiding this comment

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

i know this isnt your code but we shoudlnt be wrapping the result in a Result - can just fail the CompletableDeferred with completeExceptionally

Copy link
Author

@CharlesEtieve CharlesEtieve Aug 7, 2022

Choose a reason for hiding this comment

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

So instead of response.complete(Result.failure(exception)) we should do response.completeExceptionally(exception)?

}
Expand Down