-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirebaseMethods.js
39 lines (35 loc) · 995 Bytes
/
firebaseMethods.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
34
35
36
37
38
39
import * as firebase from "firebase";
import "firebase/firestore";
import {Alert} from "react-native";
export async function registration(email, password, lastName, firstName) {
try {
await firebase.auth().createUserWithEmailAndPassword(email, password);
const currentUser = firebase.auth().currentUser;
const db = firebase.firestore();
db.collection("users")
.doc(currentUser.uid)
.set({
email: currentUser.email,
lastName: lastName,
firstName: firstName,
});
} catch (err) {
Alert.alert("There is something wrong!", err.message);
}
}
export async function signIn(email, password) {
try {
await firebase
.auth()
.signInWithEmailAndPassword(email, password);
} catch (err) {
Alert.alert("There is something wrong!", err.message);
}
}
export async function loggingOut() {
try {
await firebase.auth().signOut();
} catch (err) {
Alert.alert('There is something wrong!', err.message);
}
}