Skip to content

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

Merged
merged 5 commits into from
Aug 11, 2017
Merged

Implementing Phone Auth Support #60

merged 5 commits into from
Aug 11, 2017

Conversation

hiranya911
Copy link
Contributor

  • Added FirebaseAuth.getUserByPhoneNumber() method.
  • Added setPhoneNumber() method to CreateRequest and UpdateRequest types.
  • Exposing phone number via UserInfo and UserRecord types.

go/firebase-java-phone-auth

@hiranya911
Copy link
Contributor Author

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].*$"),
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

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. Added Nullable to appropriate method arguments, and also updated the javadoc of setPhoneNumber().

@hiranya911
Copy link
Contributor Author

Made the suggested changes.

@hiranya911 hiranya911 merged commit 6cd505b into master Aug 11, 2017
@hiranya911 hiranya911 deleted the hkj-phone-auth branch August 11, 2017 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants