title: Firebase cloud firestore + auth: write only for signed in users
body: <p>I am building a vuejs application and I am trying to add firebase auth to the app. I used cloud firestore for a news system.</p>
  
  <p>Now on the "add news" page I call </p>
  
  <pre><code>firebase.auth().signInWithEmailAndPassword("john@doe.com", "mypassword").catch(function (error) {
    console.log(error.code);
    console.log(error.message);
  
    if (errorCode === 'auth/wrong-password') {
      alert('Wrong password.');
    } else {
      alert(errorMessage);
    }
  });
  </code></pre>
  
  <p>to log the user in, or give him feedback if something went wrong.</p>
  
  <p>Later I am writing data to cloud firestore like this</p>
  
  <pre><code>irestore.collection("news").doc().set({
    date: today,
    title: "Hello",
    text: "A think I am a news!"
  });
  </code></pre>
  
  <p>In the firestore rules I set </p>
  
  <pre><code>allow read, write: if request.auth != null;
  </code></pre>
  
  <p>to the news collection - so it should only grant write access to logged in users, right?</p>
  
  <p><strong>Now the thing:</strong>
  If i log in with a wrong password, firebase gives back, that the password was incorrect (so we are not logged in are we?) but the data is written to firestore anyways. What did I do wrong?</p>
  
  <p><a href="https://i.stack.imgur.com/EyVWu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EyVWu.png" alt="enter image description here"></a></p>