Skip to content

Commit ad71eae

Browse files
committedNov 19, 2018
04-Firebase's Authentication API
1 parent 34d1887 commit ad71eae

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎src/components/Firebase/firebase.js

+18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import app from 'firebase/app';
2+
import 'firebase/auth';
23

34
const config = {
45
apiKey: process.env.REACT_APP_API_KEY,
@@ -12,7 +13,24 @@ const config = {
1213
class Firebase {
1314
constructor() {
1415
app.initializeApp(config);
16+
17+
this.auth = app.auth();
1518
}
19+
20+
// *** Auth API ***
21+
22+
doCreateUserWithEmailAndPassword = (email, password) =>
23+
this.auth.createUserWithEmailAndPassword(email, password);
24+
25+
doSignInWithEmailAndPassword = (email, password) =>
26+
this.auth.signInWithEmailAndPassword(email, password);
27+
28+
doSignOut = () => this.auth.signOut();
29+
30+
doPasswordReset = email => this.auth.sendPasswordResetEmail(email);
31+
32+
doPasswordUpdate = password =>
33+
this.auth.currentUser.updatePassword(password);
1634
}
1735

1836
export default Firebase;

0 commit comments

Comments
 (0)
Please sign in to comment.