# #javascript #html #firebase #firebase-authentication
Вопрос:
Firebase мы пишем «Ошибка ссылки: регистрация не определена», и я не знаю, как исправить функцию singUP; никто не пытается исправить ее около 40 дней, конечно, не каждый день, но меня это просто раздражает.
Но теперь у каких основных вещей есть проблема с поиском этой функции Регистрации Firebase, я не знаю, в чем проблема.
код js :
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
document.getElementById("user_div").style.display = "block";
document.getElementById("login_div").style.display = "none";
var user = firebase.auth().currentUser;
if(user != null){
var email_id = user.email;
document.getElementById("user_para").innerHTML = "Welcome User : " email_id;
}
} else {
// No user is signed in.
document.getElementById("user_div").style.display = "none";
document.getElementById("login_div").style.display = "block";
}
});
function signUp(){
var email = document.getElementById("email");
var password = document.getElementById("password");
const promise = auth.createUserWithEmailAndPassword(email.value, password.value);
promise.catch(e => alert(e.message));
}
function login(){
var userEmail = document.getElementById("email_field").value;
var userPass = document.getElementById("password_field").value;
firebase.auth().signInWithEmailAndPassword(userEmail, userPass).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
window.alert("Error : " errorMessage);
// ...
});
}
function logout(){
firebase.auth().signOut();
}
html code :
<html>
<head>
<!--------------------------------------------------------->
<!DOCTYPE html>
<html>
<!--------------------------------------------------------->
<title>login</title>
<!------------------------ META 2020 ------------------------>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1, shrink-to-fit=no">
<meta property="og:site_name" content="test">
<meta content="Testing login" property="og:description">
<meta name="author" content="TEST">
<meta content="logo.png" property="og:image">
<link type="application/json oembed" href="https://em.0x71.cc/d2rvby.json">
<meta name="theme-color" content="#03adfc">
<link rel="icon" href="logo.png" type="image/icon type">
<!------------------------ ----------------- ------------------------>
<link href="https://fonts.googleapis.com/css?family=Nunito:400,600,700" rel="stylesheet">
<link rel="stylesheet" href="login.css" />
<!--------------- BOOSTRAP 4 ------------------------>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!------------------------ BOOSTRAP 4 END ------------------------>
</head>
<body>
<div class="alert alert-warning">
<strong>test</strong> tes boostrap
</div>
<script src="login.js"></script>
<div id="login_div" class="main-div">
<h3>HEEXY Přihlasit se</h3>
<input type="email" placeholder="Email..." id="email_field" />
<input type="password" placeholder="password..." id="password_field" />
<button onclick="login()">Login</button>
<h1></h1>
<button onclick="signUp()">Singup</button>
<h1></h1>
</div>
<div id="user_div" class="loggedin-div">
<h3>Welcome</h3>
<p id="user_para">Welcome yey</p>
<button onclick="logout()">Logout</button>
</div>
<script src="https://www.gstatic.com/firebasejs/4.8.1/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "XXX",
authDomain: "XXX",
databaseURL: "XXX",
projectId: "XXX",
storageBucket: "XXX",
messagingSenderId: "XXX"
};
firebase.initializeApp(config);
</script>
<script src="login.js"></script>
</body>
</html>
И СЛЕДУЮЩИЙ СЦЕНАРИЙ