-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
109 lines (97 loc) · 4.4 KB
/
index.html
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<title>Firebase - Log In</title>
</head>
<body>
<div class="container text-white">
<div class="row text-center">
<div class="center">
<img class="firebase-logo" src="images/firebase-logo.png">
<h1 class="title">Firebase!</h1>
</div>
</div>
<div class="divider">
</div>
<form id="sign-on">
<h2 class="text-center text-white">Sign In:</h2>
<div id="bad-login" class="alert alert-danger" role="alert">
Username or password incorrect!
</div>
<div class="form-group">
<label for="sign-in-email">Email address</label>
<input type="email" class="form-control" id="sign-in-email" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="sign-in-password">Password</label>
<input type="password" class="form-control" id="sign-in-password" placeholder="Password">
</div>
<button type="submit" class="btn btn-secondary">Sign In</button>
</form>
<div class="divider">
</div>
<div class="text-center">
<h4>No account?</h4>
<button id="create" class="btn btn-secondary">Create one now!</button>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- Insert these scripts at the bottom of the HTML, but before you use any Firebase services -->
<!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/5.11.0/firebase-app.js"></script>
<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/5.11.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.11.0/firebase-database.js"></script>
<script>
$(document).on('click', '#create', function(event){
event.preventDefault();
window.location.href="create.html";
});
</script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyAgzAsV_UpScN4wlOAvkiWJKpUyLBNiNwc",
authDomain: "fir-test-19402.firebaseapp.com",
databaseURL: "https://fir-test-19402.firebaseio.com",
projectId: "fir-test-19402",
storageBucket: "fir-test-19402.appspot.com",
messagingSenderId: "344207697807",
appId: "1:344207697807:web:de46918b01d5800d"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
$(document).on('submit', '#sign-on', function(event){
event.preventDefault();
firebase.auth().signInWithEmailAndPassword($('#sign-in-email').val(), $('#sign-in-password').val()).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
console.log($('#sign-in-email').val());
console.log($('#sign-in-password').val());
$('#bad-login').css('display', 'block');
});
});
firebase.auth().onAuthStateChanged(function(user) {
console.log(user);
if(user != null){
window.location.href="authenticated.html";
}
else{
//$('#bad-login').css('display', 'block');
}
});
</script>
</body>
</html>