-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·155 lines (105 loc) · 5.01 KB
/
index.html
File metadata and controls
executable file
·155 lines (105 loc) · 5.01 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="dep/bootstrap/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!--<link rel="icon" href="images/icon.png"> -->
<title>MitchVendor Login</title>
<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" type="text/css" href="styles/loginStyle.css">
</head>
<body class="text-center" >
<form class="form-signin" id = "loginPage">
<img class="mb-4" src="images/largeLogo.png" alt="" width="260" height="220">
<h1 class="h3 mb-3 font-weight-normal">Please Sign In</h1>
<div class = "errorTextDiv">
<h6 id = errorText > </h6>
</div>
<label for="inputEmail" class="sr-only">Email Address</label>
<input type="email" id="inputEmail" onkeypress="handleKeyPress(event)" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" onkeypress="handleKeyPress(event)" class="form-control" placeholder="Password" required>
<div class="checkbox mb-3">
<label> <input type="checkbox" value="remember-me"> Remember me </label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="button" onclick="doLogin()">Sign In</button>
<a class= "createAccountButton" href = ./signup.html style = "display:block"> Create An Account </a>
<a class="mt-5 mb-3 text-muted" >© MitchVendor 2020</a>
</form>
<!-- JQuery Include ( WEB SOURCE ) -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<!-- Bootstrap Include ( WEB SOURCE ) -->
<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>
<!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.7.0/firebase-app.js"></script>
<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/7.7.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.7.0/firebase-firestore.js"></script>
<script type="text/javascript">
var firebaseConfig = {
apiKey: "AIzaSyC4EQ21Gr2shjdcvQPPEMyAM9Q48LHIYo4",
authDomain: "mitchvending-9bfc8.firebaseapp.com",
databaseURL: "https://mitchvending-9bfc8.firebaseio.com",
projectId: "mitchvending-9bfc8",
storageBucket: "mitchvending-9bfc8.appspot.com",
messagingSenderId: "475373845114",
appId: "1:475373845114:web:0d153677affa6cc6d619c3",
measurementId: "G-1FM631J6S6"
};
firebaseMain = firebase.initializeApp(firebaseConfig,"mitchVendorWeb");
firebaseMain.auth();
function handleKeyPress(e){
var key=e.keyCode || e.which;
if (key==13){
doLogin();
}
}
function doLogin () {
var email = document.getElementById('inputEmail').value;
var password = document.getElementById('inputPassword').value;
var success = firebaseMain.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode === 'auth/wrong-password') {
document.getElementById('errorText').innerHTML = "ERROR: WRONG PASSWORD";
document.getElementById('errorText').style.color = '#f00404';
return;
}
else {
alert(errorMessage);
return;
}
})
.then(function(userCredential){
if(userCredential != undefined) {
console.log(userCredential);
document.getElementById('errorText').innerHTML = "SUCCESS:REDIRECTING...";
document.getElementById('errorText').style.color = '#07a503';
redirectLogin();
}
else {
console.log( "LOGIN FAILURE!!");
}
});
}
function resolveAfter2Seconds(x) {
return new Promise(resolve => {
setTimeout(() => {
resolve(x);
}, 1300);
});
}
async function redirectLogin() {
var x = await resolveAfter2Seconds(10);
document.location.href = "./dashboard.html"
}
firebaseMain.auth().onAuthStateChanged(function(user) {
if (user) {
console.log(firebaseMain.auth().currentUser);
}
});
</script>
</body>
</html>