I am facing an issue in firebase web-based authentication. There is no error returning in the console from firebase, I purposefully tried different combinations of wrong password and email id but there is no error in logged in the console. By using correct login username(email) and password there is nothing showing and by stepping the code using chrome-dev-tools the function is not executing. can someone help? Thanks in Advance...
Given the javaScript code and HTML codes below could you please verify the code confirm something I missed??
But everything in android application working fine for this same Project
Added localhost in the domain under authentication and I am running the app in localhost.
login.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<script src="https://www.gstatic.com/firebasejs/7.2.3/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.2.3/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.2.3/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.2.3/firebase-firestore.js"></script>
<script src = "js/firebase.js"></script>
<script src="js/main.js"></script>
<script src="js/userOperations.js"></script>
<!--===============================================================================================-->
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<form class="login100-form validate-form p-l-40 p-r-40 p-t-178">
<span class="login100-form-title">
<img src="./img/logo.png">
</span>
<div class="wrap-input100 validate-input m-b-16" data-validate="Please enter username">
<input class="input100" type="email" placeholder="Email" id = "username">
<span class="focus-input100"></span>
</div>
<div class="wrap-input100 validate-input m-b-16" data-validate = "Please enter password">
<input class="input100" type="password" placeholder="Password" id = "password">
<span class="focus-input100"></span>
</div>
<div class="container-login100-form-btn ">
<button onclick="signIn()" class="login100-form-btn shadow">
LOGIN
</button>
</div>
<div class="text-right p-t-13 p-b-23">
<span class="txt1">
<a href="register_selection.html">
Register Now
</a>
</span>
<span class="txt2">
<a href="recover.html">
Forgot Password?
</a>
</span>
</div>
<div class="flex-col-c p-t-70 p-b-40">
<span class="txt4 p-b-9">
Copyright © 2019
</span>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
firebase.js
<!-- language: lang-javascript -->
// Your web app's Firebase configuration
var firebaseConfig = {
// added the required codes here
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
//Handle Account Status
firebase.auth().onAuthStateChanged(user => {
if(user) {
window.alert("logged in");
}
});
const auth = firebase.auth();
function signIn(){
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
console.log(username+password);
firebase.auth().signInWithEmailAndPassword(username, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorCode+""+errorMessage);
// ...
});
}