authRef .currentUser .sendEmailVerification() .then(() => { this.setState({ emailSent: true }); });
const signOut = () => { return firebase.auth().signOut() .then(() => { setSession(); }) .catch((error) => { setSession(); }); }
beforeEach((done) => { const expensesData = {} expenses.forEach(({ id, description, note, amount, createdAt }) => { expensesData[id] = { description, note, amount, createdAt} }); database.ref(`users/${uid}/expenses`).set(expensesData).then(() => done()) });
const saveEmployee = ({name, phone, shift, uid}) => { const {currentUser} = firebase.auth(); return (dispatch) => { firebase.database().ref(`/users/${currentUser.uid}/employees/${uid}`) .set({name, phone, shift}) .then(() => { dispatch({type: SAVE_EMPLOYEE_SUCCESS}); Actions.employeeList({type: 'reset'}); }); //TODO catch error } }
const loginUser = ({email, password}) => { return (dispatch) => { dispatch({type: LOGIN_USER}); firebase.auth().signInWithEmailAndPassword(email, password) .then((user) => loginUserSuccess(dispatch, user)) .catch(() => loginUserFail(dispatch)) } }
// You might also want to give the user the option to reset their password // in case the account was compromised: authRef .sendPasswordResetEmail(this.state.restoredEmail) .then(() => { // Password reset confirmation sent. Ask user to check their email. this.setState({ resetSent: true }); });
firebase.auth().signOut().then(() => { navigator.pop(); }, function (error) { // An error happened. });
// Save the new password. authRef .confirmPasswordReset(actionCode, newPassword) .then(() => { // Password reset has been confirmed and new password updated. this.setState({ success: true }); }, error => { // Error occurred during confirmation. The code might have expired or the // password is too weak. this.setState({ error: error.message }); });
const deleteEmployee = ({uid}) => { const {currentUser} = firebase.auth(); return () => { firebase.database().ref(`/users/${currentUser.uid}/employees/${uid}`) .remove() .then(() => { Actions.employeeList({type: 'reset'}); }); //TODO catch error }; }
const createUser = ({email, password}) => { return (dispatch) => { dispatch({type: CREATE_USER}); firebase.auth().createUserWithEmailAndPassword(email, password) .then((user) => loginUserSuccess(dispatch, user)) .catch(() => createUserFail(dispatch)); } }
authRef .signOut() .then(() => { browserHistory.push('/'); });
authRef .currentUser .updatePassword(newPassword) .then(() => { this.setState({ success: true, working: false }); }, error => { this.setState({ error: error.message, working: false }); });
authRef .signInWithEmailAndPassword(email, password) .then(() => { browserHistory.push('/home'); }, error => { this.setState({ error: error.message, working: false }); });
authRef .sendPasswordResetEmail(email) .then(() => { this.setState({ formSent: true, working: false }); }, error => { this.setState({ error: error.message, working: false }); });
authRef .createUserWithEmailAndPassword(email, password) .then(() => { browserHistory.push('/home') }, error => { this.setState({ error: error.message, working: false }); });