forked from KamandPrompt/CodeManiacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
authenticate.js
39 lines (34 loc) · 1.01 KB
/
authenticate.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
var firebase = require('firebase');
var config = {
apiKey: "AIzaSyC8Qd4lGFTLkhRIMbBZuX7ieyJPZ3A9EgI",
authDomain: "codemaniacs-547ed.firebaseapp.com",
databaseURL: "https://codemaniacs-547ed.firebaseio.com",
storageBucket: "codemaniacs-547ed.appspot.com",
};
firebase.initializeApp(config);
function signUp(email, password, respond, callback){
firebase.auth().createUserWithEmailAndPassword(email, password)
.then( function(){
respond();
})
.catch(function(error){
callback(error);
});
}
function signIn(email, password, respond, callback){
firebase.auth().signInWithEmailAndPassword(email, password)
.then( function(){
respond();
})
.catch(function(error){
callback(error);
});
}
function signOut(respond, callback){
firebase.auth().signOut().then(function(){
respond();
}).catch(function(error){
callback(error);
});
}
module.exports = {signUp, signIn, signOut}