function addUserToDB(username, dispatch) {
  let uid = firebaseApp.auth().currentUser.uid;
  var addUser = functions.httpsCallable("user-addUserToDB");
  addUser({ uid: uid, username: username })
    .then(() => {
      navigate("Main");
    })
    .catch((error) => {
      //logic to delete the user from firebase authentication if database connection failed.
      var user = firebaseApp.auth().currentUser;
      user
        .delete()
        .then(function () {
          signout();
        })
        .catch((error) => {
          showError(error, dispatch);
        });
      showError(error, dispatch);
    });
}
//adds the new user to the db
adds the new user to the db
adds the new user to the db
function addUserToDB(username, dispatch) {
  let uid = firebaseApp.auth().currentUser.uid;
  var addUser = functions.httpsCallable("user-addUserToDB");
  addUser({ uid: uid, username: username })
    .then(() => {
      navigate("Main");
    })
    .catch((error) => {
      var user = firebaseApp.auth().currentUser;
      user
        .delete()
        .then(function () {
          signout();
        })
        .catch((error) => {
          showError(error, dispatch);
        });
      showError(error, dispatch);
    });
}
function addUserToDB ( username , dispatch ) { let uid = firebaseApp . auth ( ) . currentUser . uid ; var addUser = functions . httpsCallable ( "user-addUserToDB" ) ; addUser ( { uid : uid , username : username } ) . then ( ( ) => { navigate ( "Main" ) ; } ) . catch ( ( error ) => { var user = firebaseApp . auth ( ) . currentUser ; user . delete ( ) . then ( function ( ) { signout ( ) ; } ) . catch ( ( error ) => { showError ( error , dispatch ) ; } ) ; showError ( error , dispatch ) ; } ) ; }
adds the new user to the db
adds the new user to the db
//logic to delete the user from firebase authentication if database connection failed.