-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login.html
231 lines (203 loc) · 6.58 KB
/
Login.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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
<link href="https://fonts.googleapis.com/css?family=Sulphur+Point&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Cookie|Great+Vibes|Mr+Dafoe|Rock+Salt|Sacramento&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css\style.css">
<link rel="stylesheet" href="cdn\bootstrap.min.css">
<link rel="stylesheet" href="cdn\fonts.css">
<style>
.newew
{
display: flex;
align-items: center;
justify-content: center;
margin-top:150px ;
width: 400px;
margin-left: 500px;
padding: 12px 20px;
}
.hnadd
{
display: flex;
align-items: center;
justify-content: center;
margin-top:20px ;
width: 400px;
margin-left: 500px;
padding: 12px 20px;
}
.hnadd:hover
{
box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.3);
}
.newew:hover
{
box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.3);
}
#username
{
padding: 10px;
padding-top: 10px;
background: none;
border: 1px solid rgb(136, 126, 126);
border-radius: 30px;
}
#email
{
margin-top: -40px;
padding: 10px;
background: none;
border: 1px solid rgb(136, 126, 126);
border-radius: 30px;
}
#password
{
margin-top: -50px;
padding: 10px;
background: none;
border: 1px solid rgb(136, 126, 126);
border-radius: 30px;
}
#holll
{
margin: 10px;
margin-left: 50px;
}
#Lemail
{
margin-top: -40px;
padding: 10px;
background: none;
border: 1px solid rgb(136, 126, 126);
border-radius: 30px;
}
#Lpassword
{
margin-top: -50px;
padding: 10px;
background: none;
border: 1px solid rgb(136, 126, 126);
border-radius: 30px;
}
#holl2
{
margin: 10px;
margin-left: 50px;
}
</style>
</head>
<body>
<div class="newew">
<form id="signup" style="display:none"><h1 class="crus">Create user</h1>
<label for="username">Username</label> <br>
<input type="text" id="username"> <br> <br>
<label for="email">Email</label> <br>
<input type="email" id="email"> <br> <br>
<label for="password">Password</label> <br>
<input type="password" id="password"> <br>
<button type="button" id="holll" class="btn btn-primary" onclick="signup()"> Signup </button>
</form>
</div>
<div class="hnadd">
<form id="signin" style="display:none">
<label for="Lemail">Email</label> <br>
<input type="email" id="Lemail"> <br> <br>
<label for="Lpassword">Password</label> <br>
<input type="password" id="Lpassword"> <br>
<button type="button" id="holl2" class="btn btn-primary" onclick="signin()"> Signin </button>
</form>
</div>
</body>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyBKoRhhZ0QJ0wOcg3QTJHbr_62BUbcd7ts",
authDomain: "vinegar-food-s.firebaseapp.com",
databaseURL: "https://vinegar-food-s.firebaseio.com",
projectId: "vinegar-food-s",
storageBucket: "vinegar-food-s.appspot.com",
messagingSenderId: "990858698465",
appId: "1:990858698465:web:fd2446f481637e3378a1a0",
measurementId: "G-PYDBNEL5MW"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
let ref = firebase.database().ref();
function getElementValue(elem) {
return document.getElementById(elem).value
}
function signup() {
let username = getElementValue("username");
let email = getElementValue("email");
let pass = getElementValue("password");
firebase.auth().createUserWithEmailAndPassword(email, pass)
.then((res) => {
console.log(res);
if (res.user.uid) {
var obj = {email: email,
username: username,
Uid:res.user.uid,
displayName: username,
photoURL: "https://avatars1.githubusercontent.com/u/844211?v=4&s=460"}
ref.child("users").child(res.user.uid).set({obj});
localStorage.setItem("Login", JSON.stringify(true))
document.getElementById("signup").style.display = 'none'
document.getElementById("signin").style.display = 'block'
}
})
.catch((e) => {
console.log("error", e);
switch (e.code) {
case 'auth/weak-password':
alert(e.message)
break;
case 'auth/email-already-in-use':
alert(e.message)
break;
}
})
}
function signin() {
let email = getElementValue("Lemail");
let pass = getElementValue("Lpassword");
firebase.auth().signInWithEmailAndPassword(email, pass)
.then((res) => {
localStorage.setItem("Login", JSON.stringify(res));
alert("Your Order have been note");
localStorage.removeItem("Order");
window.location.href = "./index.html"
})
.catch((e) => {
console.log(e);
switch (e.code) {
case "auth/wrong-password": // wrong password on sign in
alert(e.message)
break;
case "auth/user-not-found": // user not found on sign in on wrong email
alert(e.message)
break;
default:
alert(e.message);
}
})
}
if (JSON.parse(localStorage.getItem("Login"))) {
document.getElementById("signin").style.display = "block";
} else {
document.getElementById("signup").style.display = "block";
}
</script>
</html>