Berikut kami update Login yang hanya menggunakan Sign in by Google saja sehingga aman dari SEO.
buat halaman baru/page di blogger dan copy paste kode berikut:
Beri judul page tersebut dan simpan
untuk menggunakan halaman demo anda harus login dahulu di website tujuan
Lihat Demo
Jika ada pertanyaan silahkan gunakan koment dibawah
buat halaman baru/page di blogger dan copy paste kode berikut:
Beri judul page tersebut dan simpan
<div id="userListContainer">
<table id="userListTable">
<thead>
<tr>
<th>User ID</th>
<th>Name</th>
<th>Email</th>
<th>Registration Date</th>
<!-- Tambahkan kolom lain sesuai kebutuhan -->
</tr>
</thead>
<tbody id="userListBody">
<!-- Data pengguna akan ditampilkan di sini -->
</tbody>
</table>
</div>
<script>
// Dapatkan referensi ke elemen tbody di tabel
var userListBody = document.getElementById('userListBody');
// Dapatkan data pengguna saat halaman dimuat
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
// Hapus data sebelumnya jika ada
userListBody.innerHTML = '';
// Tambahkan baris baru untuk setiap pengguna
var newRow = userListBody.insertRow();
newRow.insertCell().textContent = user.uid;
newRow.insertCell().textContent = user.displayName || 'N/A';
newRow.insertCell().textContent = user.email || 'N/A';
// Dapatkan tanggal pertama kali terdaftar
var creationTime = new Date(user.metadata.creationTime);
newRow.insertCell().textContent = creationTime.toDateString();
// Tambahkan kolom lain sesuai kebutuhan
const displayName = user.displayName;
document.getElementById('namaUser').value = displayName;
const email = user.email;
document.getElementById('nomorUser').value = email;
} else {
// Pengguna tidak diotentikasi
userListBody.innerHTML = '<tr><td colspan="4">Anda belum login</td></tr>';
}
});
</script>
<style>
/* Gaya untuk tombol Login, Register, dan Logout */
.action-button {
background-color: #ff6529;
color: #fff;
border: none;
padding: 10px 20px;
margin: 5px;
cursor: pointer;
font-weight: bold;
border-radius: 5px;
}
.action-button:hover {
background-color: #c9572a;
}
</style>
<button class="action-button" id="tampilkanGoogle" onclick="signInWithGoogle()">Sign in with Google</button>
<button class="action-button" id="tampilkanLogout" onclick="signOut()" style="display: none;">Logout</button>
</br>
</br>
<div id="tampilkan" style="display: none;">Apakah anda adalah Alumni SMAN 2 Cileungsi? <a href="/p/tambah-data-alumni.html">klik disini</a></div>
<script>
// Google Sign-In function
function signInWithGoogle() {
const provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider)
.then((result) => {
// This gives you a Google Access Token.
const credential = result.credential;
// The signed-in user info.
const user = result.user;
console.log(user);
}).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
// The firebase.auth.AuthCredential type that was used.
const credential = error.credential;
console.error(errorMessage);
});
}
// Sign out function
function signOut() {
firebase.auth().signOut().then(() => {
console.log("User signed out successfully");
}).catch((error) => {
console.error("Error signing out:", error);
});
}
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
document.getElementById("tampilkanGoogle").style.display = "none";
document.getElementById("tampilkanLogout").style.display = "block";
document.getElementById("tampilkan").style.display = "block";
} else {
document.getElementById("tampilkanLogout").style.display = "none";
document.getElementById("tampilkanGoogle").style.display = "block";
document.getElementById("tampilkan").style.display = "none";
}
});
</script>
</script>
untuk menggunakan halaman demo anda harus login dahulu di website tujuan
Lihat Demo
Jika ada pertanyaan silahkan gunakan koment dibawah
Post a Comment