(user: User)
| 15 | * @param user - The user to be created in the database |
| 16 | */ |
| 17 | export const createUserInDatabase = async (user: User) => { |
| 18 | // Checks if user exists in the database |
| 19 | const userRef = doc(db, USERS_COLLECTION, user.uid); |
| 20 | const docRef = await getDoc(userRef); |
| 21 | |
| 22 | // If the user exists, return |
| 23 | if (docRef.exists()) return; |
| 24 | |
| 25 | // Saves the user in the firestore database |
| 26 | const newUser: UserDB = { |
| 27 | email: user.email!, |
| 28 | name: user.displayName, |
| 29 | }; |
| 30 | |
| 31 | await setDoc(doc(db, USERS_COLLECTION, user.uid), newUser); |
| 32 | }; |
no outgoing calls
no test coverage detected