Skip to content

Instantly share code, notes, and snippets.

@jason-dark
Created September 1, 2018 01:21
Show Gist options
  • Save jason-dark/d350958f60858cde03d6731c8679f7fc to your computer and use it in GitHub Desktop.
Save jason-dark/d350958f60858cde03d6731c8679f7fc to your computer and use it in GitHub Desktop.
<!-- logout function -->
<script>
logoutLink.addEventListener('click', logout);
function logout() {
firebase.auth().signOut();
}
</script>
<!-- login function -->
<script>
loginButton.addEventListener('click', login);
function login() {
loginButton.style.display = 'none';
loginError.style.display = 'none';
var email = loginEmail.value;
var password = loginPassword.value;
firebase.auth().signInWithEmailAndPassword(email, password)
.then(function () {
window.location.replace('./private');
})
.catch(function (error) {
var errorCode = error.code;
var errorMessage = error.message;
console.log('Error code: ' + errorCode);
console.log('Error message: ' + errorMessage);
loginButton.style.display = 'block';
loginError.innerText = errorMessage;
loginError.style.display = 'block';
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment