-
Notifications
You must be signed in to change notification settings - Fork 10
/
auth.js
34 lines (28 loc) · 874 Bytes
/
auth.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
import { auth, provider } from "../firebase";
export const signUp = (email, password) => {
return auth.createUserWithEmailAndPassword(email, password);
};
export const signIn = (email, password) => {
return auth.signInWithEmailAndPassword(email, password);
};
export const signOut = () => {
auth.signOut();
};
export const signInWithGoogle = () => {
auth
.signInWithPopup(provider)
.then((result) => console.log(`${result.user.displayName} Logged In!`))
.catch((error) => {
console.log("Login Error: ", error);
alert(error.message);
});
};
export const updateProfile = (userAuth, name, photoURL) => {
return userAuth.user.updateProfile({
displayName: name,
photoURL: photoURL || `https://ui-avatars.com/api/?name=${name}`,
});
};
export const resetPassword = (email) => {
return auth.sendPasswordResetEmail(email);
};