Skip to content

Instantly share code, notes, and snippets.

@mingsai
Created March 15, 2022 19:58
Show Gist options
  • Save mingsai/6e44dff9d4eb343c189b24d46f78ce41 to your computer and use it in GitHub Desktop.
Save mingsai/6e44dff9d4eb343c189b24d46f78ce41 to your computer and use it in GitHub Desktop.
Firebase Function to create user after phone validated
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