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

feat: add phone number authentication #110

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

lkmandy
Copy link
Contributor

@lkmandy lkmandy commented Mar 2, 2023

Description

Implement phone number authentication using firebase and flutter bloc

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

Pre-launch Checklist

Copy link
Contributor

@kefeh kefeh left a comment

Choose a reason for hiding this comment

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

This was a great start, I like the structuring and the implementations details, kudus. I left a few comments, hope it helps

Future<Either<AuthFailure, Unit>> verifyOTPCode({
required String phoneNumber,
required Duration timeOut,
required PhoneVerificationFailed phoneVerificationFailed,
Copy link
Contributor

Choose a reason for hiding this comment

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

There are three problems i have with this.

  1. A function should have a maximum of 3 parameters and others can be compiled into a unit either map or class for proper readability etc.
  2. Avoid passing callbacks as parameters if you if you can.
  3. Most importantly, you are tightly coupling this facad with Firebase by depending on the firebase specific accessory functions and it defeats the purpose of a facad, you should be able to use even SuperBase and extend this facad without an issue

required PhoneCodeAutoRetrievalTimeout autoRetrievalTimeout,
}) async {
try {
_firebaseAuth.verifyPhoneNumber(
Copy link
Contributor

Choose a reason for hiding this comment

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

What you can do here is define handlers for PhoneVerificationFailed, PhoneVerificationCompleted, PhoneCodeSent, PhoneCodeAutoRetrievalTimeout as accessory and private functions inside this Repository class and then call them here. If you realize, you see that verificationId is set and used only in this repository, so one thing you can do here is set is as a class variable initialized with an empty string, set the value in PhoneCodeSent and then use it inside verifyAndLogin


abstract class IPhoneNumberRepositoryFacade {
Future<Either<AuthFailure, bool>> verifyAndLogin({
required String verificationId,
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, remove verificationId so we dont have coupling with firebase to the facad

@lkmandy lkmandy force-pushed the implement-phone-number-authentication branch 3 times, most recently from fa00abb to b050edb Compare March 6, 2023 10:24
@lkmandy lkmandy force-pushed the implement-phone-number-authentication branch from b050edb to 07febba Compare March 16, 2023 13:40
- Configure native android files
- Implement the logic with flutterbloc
@lkmandy lkmandy force-pushed the implement-phone-number-authentication branch from 07febba to a45590f Compare March 17, 2023 22:18
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.

2 participants