aboutsummaryrefslogtreecommitdiff
path: root/shared/Login.js
blob: 6015ee52ed058baaa17f5fd408c3c6681edb584c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$(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);
      }
    $('#login').click(function(){
        var email = $("#email").val()
        var password = $("#password").val()
        if(email === '' || password === '') {
            showAlert('Please fill in all the fields')
        } else {
            firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
                // Handle Errors here.
                var errorCode = error.code;
                var errorMessage = error.message;
                showAlert(errorMessage)
                // ...
            });
        }
    })
})