title: How to find out if user has previous login credentials before signing in with google firebase auth
body: <p>I am creating my login page on my webapp and on it I have successfully implemented the google signup button. It is working fine for new users but when existing users are supposed to log in it is supposed to throw an error of 'auth/account-exists-with-different-credential' which is not being thrown, as a result the previous user data of email and password is being completely overwritten with new auth of google instead of being merged together. Here's my code snippet, any help will be appreciated</p>
  <pre class="lang-js prettyprint-override"><code>const googleProvider = new firebase.auth.GoogleAuthProvider();
  export const signinGoogle = () =&gt; {
    auth
      .signInWithPopup(googleProvider)
      .then((res) =&gt; {
        console.log(res.user);
      })
      .catch(function (error) {
        console.log(error.message);
        if (error.code === 'auth/account-exists-with-different-credential') {
          var pendingCred = error.credential;
          var email = error.email;
          auth.fetchProvidersForEmail(email).then(function (methods) {
            if (methods[0] === 'password') {
              var password = prompt('Enter your password');
              auth.signInWithEmailAndPassword(email, password).then(function (result) {
                return result.user.linkWithCredential(pendingCred);
              });
            }
          });
        }
      });
  };
  </code></pre>
  <p>I have done everything according to <a href="https://firebase.google.com/docs/auth/web/google-signin#expandable-1" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/web/google-signin#expandable-1</a> but the main problem is the error is not thrown</p>