From 769dfb05c38095d0617a9fb17c93d30277167728 Mon Sep 17 00:00:00 2001 From: Kumar Priyansh Date: Mon, 3 Jun 2019 07:44:30 +0530 Subject: Signup JS Updated --- shared/Signup.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'shared') 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 -- cgit v1.2.3