Created
March 15, 2022 19:58
-
-
Save mingsai/6e44dff9d4eb343c189b24d46f78ce41 to your computer and use it in GitHub Desktop.
Firebase Function to create user after phone validated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as admin from 'firebase-admin'; | |
const db = admin.firestore() | |
export async function onUserCreated(user: any): Promise<boolean> { | |
if(typeof user.phoneNumber != "undefined") { | |
const batch = db.batch() | |
batch.set(db.collection("users").doc(user.uid), { | |
"phoneNumber": user.phoneNumber, | |
"creationTime": new Date(user.metadata.creationTime), | |
}) | |
batch.commit() | |
return true | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment