btnsubmit.addEventListener('click', e => {
        const task = txttask.value;
        const description = txtdescription.value;
        const date = txtdate.value;
        firebase.auth().onAuthStateChanged(firebaseUser => {
            if (firebaseUser) {
                console.log(firebaseUser.email)
                firebase.database().ref('uid/' + firebaseUser.uid + '/reminders/' + date).set({
                    task: task,
                    description: description,
                    date: date,
                });
                alert('Data Has Been Recorded');
            }
        });
        document.getElementById("input_form").reset();
so when I hit the submit button I get the alert but the data is not saved.
another example
      if (firebaseUser) {
        console.log(firebaseUser);
        return window.location.href = 'index.html';
      } else {
        if (email == '' && pass == '') {
          alert('Please Enter The Email and The Password!')
        } else if (pass == '') {
          alert('Please Enter The Password!')
        } else if (email == '') {
          alert('Please Enter The Email')
        }
        else {
          if (firebaseUser) {
            console.log(firebaseUser);
            return window.location.href = 'index.html';
          } else {
            alert('Something went wrong')
          }
        }
        console.log("not loged in");
      }
    });
Here the website shows the alert that something went wrong and when I clear it I'm logged in. I added extra if to again check if the user exists just in the case. but it still does that, so I'm confused as to what am I doing wrong in both scenarios.
 
    