0

I am trying to make login and signup forms for my web app using javascript and Firebase.

I am getting an error when taking a users signup information and passing it into the signInWithEmailAndPassword function.

signInWithEmailAndPassword failed: First argument "email" must be a valid string.

I have researched for almost 3 hours now and cant find anything that could fix the issue.

failed: First argument "email" must be a valid string."

The Html

<input type="email" placeholder="email" id="email">
<input type="password" placeholder="password" id="password">

<button onclick="signUp()" id="signUp">Sign Up</button>
<button onclick="signIn()" id="signIn">Sign In</button>
<button onclick="signOut()" id="signOut">Sign Out</button>

Javascript

  function signUp(){
  
  var emaile = document.getElementById("email");
  var passworde = document.getElementById("password");

  firebase.auth().signInWithEmailAndPassword(emaile, passworde).catch(function(error) {
  alert(errorMessage)
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});
 }
 
 function signIn(){
  
  var email = document.getElementById("email");
  var password = document.getElementById("password");
  
  const promise = firebase.auth().signInWithEmailAndPassword(email, password).promise.catch(e => alert(e.message));
   
 }

 function signOut(){
  
  auth.signOut();
  alert("Signed Out");
  
 }
 
firebase.auth().onAuthStateChanged(function(user) {
  
  if(user){
   
   var email = user.email;
   alert("Active User " + email);
   
   //Take user to a different or home page

   //is signed in
   
  }else{
   
   alert("No Active User");
   //no user is signed in
  }
 });

Thanks in advance.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441

0 Answers0