CollActionteam / collaction_api

The API powering the Collaction Client Applications
GNU Affero General Public License v3.0
7 stars 0 forks source link

[Followers] Lookup Phone Number #49

Open MichaelSlatteryDev opened 2 years ago

MichaelSlatteryDev commented 2 years ago

For the followers feature in the future the backend needs to be able to use a phone number from a users contacts to fetch userIds. We store the users phone number with Firebase Authentication. It seems the userId across the backend and Firebase is the same so assuming we can fetch users from Firebase using their phone number it should then be simple to do the rest in the backend with the findUserByIdOrFail function.

gnoulelem commented 2 years ago

I added a new method findUserByPhoneNumber in the Authentication service to retrieve a user from Firebase by providing his phone number. For doing so I used the getUserByPhoneNumber method provide by Firebase admin SDK.

getAuth() .getUserByPhoneNumber(phoneNumber)

We can also get several users with the getUsers method

getAuth() .getUsers([ { uid: 'uid1' }, { email: 'user2@example.com' }, { phoneNumber: '+15555550003' }, { providerId: 'google.com', providerUid: 'google_uid4' }, ])

Xazin commented 2 years ago

I added a new method findUserByPhoneNumber in the Authentication service to retrieve a user from Firebase by providing his phone number. For doing so I used the getUserByPhoneNumber method provide by Firebase admin SDK.

getAuth() .getUserByPhoneNumber(phoneNumber)

We can also get several users with the getUsers method

getAuth() .getUsers([ { uid: 'uid1' }, { email: 'user2@example.com' }, { phoneNumber: '+15555550003' }, { providerId: 'google.com', providerUid: 'google_uid4' }, ])

Can you push your branch, and let's make a PR for this, then I will start mapping out what more we need for this feature that we currently know of.

gnoulelem commented 2 years ago

The branch is already pushed : feat/get-user-by-phone-number

Xazin commented 2 years ago

The branch is already pushed : feat/get-user-by-phone-number

You can open a PR and we can take a look at it and see if it needs more work or if we can merge it

gnoulelem commented 2 years ago

I opened the PR.