-
Notifications
You must be signed in to change notification settings - Fork 289
Implementing Phone Auth Support #60
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
Conversation
Related to #56 |
// Phone number verification is very lax here. Backend will enforce E.164 spec compliance, and | ||
// normalize accordingly. | ||
checkArgument(!Strings.isNullOrEmpty(phoneNumber), "phone number cannot be null or empty"); | ||
checkState(phoneNumber.matches("^\\+.*[a-zA-Z0-9].*$"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read this correctly, this merely verifies that the phone number starts with '+' and contains at least one 'normal' character. So +&&&a&&& might be a valid number? If that is our level of verification, then we might as well let the server handles it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified this to check only for the +
prefix. Updated the error message accordingly. We can rely on the backend server for more comprehensive validation of phone numbers.
* | ||
* @param phone a valid phone number string or null. | ||
*/ | ||
public UpdateRequest setPhoneNumber(String phone) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not want to use Nullable here? (and everywhere else).
I feel we shouldn't be calling this out in our comments but rather in our code. Furthermore, it is not clear from the comment what setting the number to 'null' entails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Added Nullable
to appropriate method arguments, and also updated the javadoc of setPhoneNumber()
.
Made the suggested changes. |
FirebaseAuth.getUserByPhoneNumber()
method.setPhoneNumber()
method toCreateRequest
andUpdateRequest
types.UserInfo
andUserRecord
types.go/firebase-java-phone-auth