diff options
| author | Kumar Priyansh <[email protected]> | 2019-06-03 07:44:30 +0530 |
|---|---|---|
| committer | Kumar Priyansh <[email protected]> | 2019-06-03 07:44:30 +0530 |
| commit | 769dfb05c38095d0617a9fb17c93d30277167728 (patch) | |
| tree | 2dedd9368ff157309c71f49ed2c7be0ce7552d46 /shared | |
| parent | 9f73b94c96892f57e9c7eb2495a20aaba9c5c3a6 (diff) | |
| download | firebase-ecommerce-769dfb05c38095d0617a9fb17c93d30277167728.tar.xz firebase-ecommerce-769dfb05c38095d0617a9fb17c93d30277167728.zip | |
Signup JS Updated
Diffstat (limited to 'shared')
| -rw-r--r-- | shared/Signup.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/shared/Signup.js b/shared/Signup.js index e69de29..8902a68 100644 --- a/shared/Signup.js +++ b/shared/Signup.js @@ -0,0 +1,32 @@ +$(document).ready(function(){ + function showAlert(message) { + // Get the snackbar DIV + var x = document.getElementById("snackbar"); + $('#snackbar').text(message) + // Add the "show" class to DIV + x.className = "show"; + + // After 3 seconds, remove the show class from DIV + setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000); + } + $('#signup').click(function(){ + var email = $("#email").val() + var password = $("#password").val() + if(email === '' || password === '') { + showAlert('Please fill in all the fields') + } else { + firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) { + // Handle Errors here. + var errorCode = error.code; + var errorMessage = error.message; + showAlert(errorMessage) + // ... + }); + } + }) + firebase.auth().onAuthStateChanged(function(user) { + if (user) { + window.location.replace('dashboard') + } + }); +})
\ No newline at end of file |
