0

i am trying to get my login page to refresh once a user enters the wrong account details. my problem is the page doesnt refesh once submitted the old details are not removed. how can i clear the page so the user can try again adding there account details

function signOut(email, password) {

   auth.signOut().then(function() {
      // Sign-out successful.
   }).catch(function(error) {
     // An error happened.
   });
};

1 Answers1

0

In signIn() function, when user will enter wrong details then it will come in error function at that time just refresh your page like this-

function signIn() {
        var email = $('#username').val();
        var password = $('#Password').val();

        initFirebase()
    auth.signInWithEmailAndPassword(email, password).then(
        function(user) {
            console.log(user)
            loginUsrEmail = user.email
            console.log(user.email)
            getData(loginUsrEmail)
        },
        function(error) {
            location.reload();        
        });

      };

Hope this will help you.

Suniti Yadav
  • 393
  • 2
  • 8
  • your welcome... and please accept my answer if it satisfied you. – Suniti Yadav Apr 03 '18 at 06:13
  • sorry to ask you before i was getting the message your email is wrong. and now i dont get the alerts only referesh the page. how can i get the alert messages. thank you for helping – Buildaholic zak Zak Apr 03 '18 at 06:18
  • put your alert message code before refresh code. it will give you alert and then it will refresh your page. – Suniti Yadav Apr 03 '18 at 06:23
  • like this - function(error) { console.log(error) var errorCode = error.code; var errorMessage = error.message; alert("" + errorMessage); location.reload(); }); – Suniti Yadav Apr 03 '18 at 06:36