Я следовал документации Firebase для добавления входа: https://firebase.google.com/docs/auth/web/firebaseui?authuser=0
Вот код для входа в систему и HTML для дисплея, который я использовал:
var ui = new firebaseui.auth.AuthUI(firebase.auth());
var uiConfig = {
callbacks: {
signInSuccessWithAuthResult: function(authResult, redirectUrl) {
return true;
},
uiShown: function() {
document.getElementById('loader').style.display = 'none';
}
},
signInFlow: 'popup',
signInSuccessUrl: 'dashboard.html',
signInOptions: [
//firebase.auth.GoogleAuthProvider.PROVIDER_ID,
//firebase.auth.FacebookAuthProvider.PROVIDER_ID,
//firebase.auth.TwitterAuthProvider.PROVIDER_ID,
//firebase.auth.GithubAuthProvider.PROVIDER_ID,
firebase.auth.EmailAuthProvider.PROVIDER_ID,
//firebase.auth.PhoneAuthProvider.PROVIDER_ID
],
tosUrl: 'index.html',
privacyPolicyUrl: 'index.html'
};
ui.start('#firebaseui-auth-container', uiConfig);
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Login</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script src="https://www.gstatic.com/firebasejs/6.1.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.1.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.1.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.1.0/firebase-firestore.js"></script>
<script src="https://cdn.firebase.com/libs/firebaseui/3.5.2/firebaseui.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/3.5.2/firebaseui.css" />
</head>
<body>
<h1>Welcome to Login</h1>
<div id='firebaseui-auth-container'></div>
<div id="loader">Loading...</div>
<script src="firebase.js"></script>
<script src="login.js"></script>
</body>
</html>
Когда я запускаю свой сервер на локальном хосте, я не вижу аутентификацию электронной почты в своем браузере, но когда я просто дважды щелкаю по своей html-странице, я вижу ее.Вот мои ошибки в консоли:
It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.
For the CDN builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):
https://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js
index.cdn.ts:18
[2019-05-31T18:13:57.308Z] @firebase/app:
Warning: Firebase is already defined in the global scope. Please make sure
Firebase library is only loaded once.