Created
September 1, 2018 01:44
-
-
Save jason-dark/12419190fcfe41fc480ade1bb7c904ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- signup function --> | |
<script> | |
signupButton.addEventListener('click', signup); | |
function signup() { | |
signupButton.style.display = 'none'; | |
signupError.style.display = 'none'; | |
var email = signupEmail.value; | |
var password = signupPassword.value; | |
firebase.auth().createUserWithEmailAndPassword(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); | |
signupButton.style.display = 'block'; | |
signupError.innerText = errorMessage; | |
signupError.style.display = 'block'; | |
}); | |
} | |
</script> | |
<!-- auth state function --> | |
<script> | |
firebase.auth().onAuthStateChanged(function (user) { | |
if (user) { | |
// User is signed in. | |
console.log('User is logged in!'); | |
console.log('Email: ' + user.email); | |
console.log('UID: ' + user.uid); | |
} else { | |
// User is signed out. | |
console.log('No user is logged in'); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment