-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
33 lines (30 loc) · 833 Bytes
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const config = { /* insert config here */};
firebase.initializeApp(config).firestore();
async function main() {
const email = 'insert@unique.email';
const password = 'passwordwoohoo';
const name = 'Some name';
firebase
.auth()
.createUserWithEmailAndPassword(email, password)
.then((result) => {
firebase
.firestore()
.collection('users')
.doc(firebase.auth().currentUser.uid)
.set({
name,
email,
});
console.log('result', result);
})
.catch((error) => {
if (error.code === 'auth/email-already-in-use') {
console.log('Error', 'That email address is already in use!');
}
if (error.code === 'auth/invalid-email') {
console.log('Error', 'That email address is invalid!');
}
});
}
main();