'signInOptions': [ provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID }, provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
getInitialView() { firebase.auth().onAuthStateChanged((user) => { let initialView = user ? "Home" : "Login"; this.setState({ userLoaded: true, initialView: initialView }) }); }
signIn() { const { email, password } = this.state; firebaseApp.auth().signInWithEmailAndPassword(email, password) .then(this.props.history.push('/app')) .catch(error => { this.setState({error}); }) }
firebase.auth().signOut().then(() => { navigator.pop(); }, function (error) { // An error happened. });
onLoginPress() { this.setState({ error: '', loading: true }); const { email, password } = this.state; firebase.auth().signInWithEmailAndPassword(email, password) .then(() => { this.setState({ error: '', loading: false }); this.props.navigation.navigate('Home'); }) .catch(() => { this.setState({ error: 'Authentication failed', loading: false }); }); }
firebase.auth() .createUserWithEmailAndPassword(email, password) .catch((error) => { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; this.setState({ errorMessage, loading: false }) });
signUp() { const { email, password } = this.state; firebaseApp.auth().createUserWithEmailAndPassword(email, password) .catch(error => { this.setState({error}); }) }
const AuthContextProvider = ({ children }) => { const [user, setUser] = useState(() => { const user = firebase.auth().currentUser; return user; }); useEffect(() => { firebase.auth().onAuthStateChanged(firebaseUser => { setUser(firebaseUser); }); }, []) return <AuthContext.Provider value={user}>{children}</AuthContext.Provider> }
const startLogin = () => { return () => { return firebase.auth().signInWithPopup(googleAuthProvider); }; }
componentDidMount(){ firebase.auth().onAuthStateChanged((authenticate)=>{ if (authenticate) { this,this.props.navigation.replace('Home') } else { this,this.props.navigation.replace('Signin') } }) }
signIn() { const { email, password } = this.state; firebaseApp.auth().signInWithEmailAndPassword(email, password) .then(() => { this.setState({isLoggedIn: true}); browserHistory.push('/newsfeed'); }) .catch(error => { this.setState({ error }); }) }
/** * @return {Promise} */ signout() { return firebase.auth().signOut(); }
'signInOptions': [ provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID }, provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
const startLogin = () =>{ return () =>{ return firebase.auth().signInWithPopup(googleAuthProvider); }; }