Skip to content

Commit

Permalink
Firebase Authentification
Browse files Browse the repository at this point in the history
  • Loading branch information
MengTo committed May 13, 2019
1 parent 73945ec commit db251fe
Show file tree
Hide file tree
Showing 4 changed files with 1,074 additions and 193 deletions.
13 changes: 13 additions & 0 deletions components/Firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as firebase from "firebase";

// Initialize Firebase
const firebaseConfig = {
apiKey: "AIzaSyCj376WDKhFfXiCQ1XZw_lm- oArYhP0ZLQ",
authDomain: "react-native-for-designers.firebaseapp.com",
databaseURL: "https://react-native-for-designers.firebaseio.com",
storageBucket: "react-native-for-designers.appspot.com"
};

firebase.initializeApp(firebaseConfig);

export default firebase;
33 changes: 24 additions & 9 deletions components/ModalLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Success from "./Success";
import Loading from "./Loading";
import { Alert, Animated, Dimensions } from "react-native";
import { connect } from "react-redux";
import firebase from "./Firebase";

const screenHeight = Dimensions.get("window").height;

Expand Down Expand Up @@ -73,17 +74,31 @@ class ModalLogin extends React.Component {

this.setState({ isLoading: true });

setTimeout(() => {
this.setState({ isLoading: false });
this.setState({ isSuccessful: true });
const email = this.state.email;
const password = this.state.password;

Alert.alert("Congrats", "You've logged successfully!");
firebase
.auth()
.signInWithEmailAndPassword(email, password)
.catch(function(error) {
Alert.alert("Error", error.message);
})
.then(response => {
console.log(response);

setTimeout(() => {
this.props.closeLogin();
this.setState({ isSuccessful: false });
}, 1000);
}, 2000);
this.setState({ isLoading: false });

if (response) {
this.setState({ isSuccessful: true });

Alert.alert("Congrats", "You've logged successfully!");

setTimeout(() => {
this.props.closeLogin();
this.setState({ isSuccessful: false });
}, 1000);
}
});
};

focusEmail = () => {
Expand Down
Loading

0 comments on commit db251fe

Please sign in to comment.