-
Notifications
You must be signed in to change notification settings - Fork 768
/
mylogin.html
388 lines (350 loc) · 14.6 KB
/
mylogin.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<title>How to create Firebase login and register?</title>
<style>
.remember-me-label {
font-size: 14px;
display: inline-flex;
align-items: center;
}
.remember-me-label input {
margin-right: 8px;
margin-top: 1px;
}
.main {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.login,
.register {
flex: 1;
margin: 10px;
padding: 20px;
border: 1px solid #ddd;
}
.input {
width: 100%;
margin: 10px 0;
padding: 10px;
box-sizing: border-box;
}
button {
width: 100%;
padding: 10px;
margin-top: 10px;
}
/* Style for highlighting valid conditions in green */
.valid-condition {
color: lightgreen;
}
/* Style for invalid conditions */
.invalid-condition {
color: red;
}
/* Hide the password conditions list by default */
#passwordConditions {
list-style: none;
padding: 0;
display: none; /* Hide initially */
}
/* Show the conditions list when the user starts typing */
.show-conditions #passwordConditions {
display: block;
}
</style>
<style>
/* Circle styles */
.circle {
height: 24px;
width: 24px;
border-radius: 50%;
background-color: black;
position: fixed;
top: 0;
left: 0;
pointer-events: none;
z-index: 99999999;
transition: transform 0.1s ease-out;
}
</style>
</head>
<body>
<!-- Circles -->
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="navbar nav_activated">
<div class="navbar-header">
<a href="index.html">
<img class="close-icon" src="./assets/images/close.png" alt="Close">
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#" id="logout" style="display: none">Log Out</a></li>
</ul>
</div>
</div>
<div class="note">
<h1>
Hey !! Welcome to SwapReads. Please get yourself Registered or verify your credentials to get started.
</h1>
</div>
<br />
<div class="container">
<div class="main">
<input type="checkbox" id="chk" aria-hidden="true" />
<div class="login">
<form class="form">
<label for="chk" aria-hidden="true">Log in</label>
<input class="input" type="email" name="email" id="login_email" placeholder="Email" required="" />
<input class="input" type="password" name="pswd" id="login_password" placeholder="Password" required="" />
<label class="remember-me-label">
<input type="checkbox" id="rememberMe"> Remember Me
</label>
<button type="button" name="Login" id="login">Log in</button>
<button type="button" id="forgotPassword">Forgot Password?</button>
</form>
</div>
<div class="register">
<form class="form">
<label for="chk" aria-hidden="true">Register</label>
<input class="input" type="email" name="email" id="email" placeholder="Email" required="" />
<input class="input" type="password" name="pswd" id="password" placeholder="Password" required="" />
<!-- Password strength conditions -->
<ul id="passwordConditions">
<li id="lengthCondition">At least 8 characters</li>
<li id="uppercaseCondition">At least 1 uppercase letter</li>
<li id="lowercaseCondition">At least 1 lowercase letter</li>
<li id="numberCondition">At least 1 number</li>
<li id="specialCharCondition">At least 1 special character</li>
</ul>
<button type="button" name="register" id="register">Register</button>
</form>
</div>
</div>
</div>
<hr>
<footer class="footer">
<div class="container">
<div class="footer-bottom">
<p class="copyright">
© <span id="copyright-year"></span> All right reserved. Made with ❤ by Guardian Hackers.
</p>
</div>
</div>
</footer>
<script>
document.getElementById("copyright-year").textContent = new Date().getFullYear();
</script>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.8.1/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.8.1/firebase-analytics.js";
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut } from "https://www.gstatic.com/firebasejs/10.8.1/firebase-auth.js";
const firebaseConfig = {
apiKey: "AIzaSyCu2WXknNce_49J5BLuR1DyHm319hu6dWc",
authDomain: "login-13127.firebaseapp.com",
projectId: "login-13127",
storageBucket: "login-13127.appspot.com",
messagingSenderId: "151656578300",
appId: "1:151656578300:web:c67208ab6ec437c844ab79",
measurementId: "G-L3PPD58MZ8"
};
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const auth = getAuth();
window.onload = function () {
if (localStorage.getItem('rememberMe') === 'true') {
document.getElementById('login_email').value = localStorage.getItem('email');
document.getElementById('login_password').value = localStorage.getItem('password');
document.getElementById('rememberMe').checked = true;
}
};
document.getElementById("register").addEventListener("click", function () {
let email = document.getElementById("email").value;
let password = document.getElementById("password").value;
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
const user = userCredential.user;
console.log(user);
alert("Registration successful!");
document.getElementById("email").value = "";
document.getElementById("password").value = "";
})
.catch((error) => {
const errorMessage = error.message;
console.log(errorMessage);
alert(errorMessage);
});
});
document.getElementById("login").addEventListener("click", function () {
let email = document.getElementById("login_email").value;
let password = document.getElementById("login_password").value;
let rememberMe = document.getElementById("rememberMe").checked;
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
if (rememberMe) {
localStorage.setItem('email', email);
localStorage.setItem('password', password);
localStorage.setItem('rememberMe', true);
} else {
localStorage.removeItem('email');
localStorage.removeItem('password');
localStorage.removeItem('rememberMe');
}
window.location.href = "index.html";
document.getElementById("logout").style.display = "block";
})
.catch((error) => {
const errorMessage = error.message;
console.log(errorMessage);
alert(errorMessage);
});
});
document.getElementById("logout").addEventListener("click", function () {
signOut(auth)
.then(() => {
console.log("Sign-out successful.");
})
.catch((error) => {
console.log("An error happened.");
});
});
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("forgotPassword").addEventListener("click", function () {
let email = document.getElementById("login_email").value;
if (email) {
auth.sendPasswordResetEmail(email)
.then(() => {
alert("Password reset email sent!");
})
.catch((error) => {
const errorMessage = error.message;
console.log(errorMessage);
alert(errorMessage);
});
} else {
alert("Please enter your email address to reset your password.");
}
});
});
</script>
<script>
// Password strength validation
const passwordInput = document.getElementById("password");
const conditionsList = document.getElementById("passwordConditions");
passwordInput.addEventListener("input", function () {
const password = passwordInput.value;
// Check conditions
const lengthCondition = password.length >= 8;
const uppercaseCondition = /[A-Z]/.test(password);
const lowercaseCondition = /[a-z]/.test(password);
const numberCondition = /\d/.test(password);
const specialCharCondition = /[!@#$%^&*(),.?":{}|<>]/.test(password);
// Toggle valid and invalid classes
document.getElementById("lengthCondition").className = lengthCondition ? "valid-condition" : "invalid-condition";
document.getElementById("uppercaseCondition").className = uppercaseCondition ? "valid-condition" : "invalid-condition";
document.getElementById("lowercaseCondition").className = lowercaseCondition ? "valid-condition" : "invalid-condition";
document.getElementById("numberCondition").className = numberCondition ? "valid-condition" : "invalid-condition";
document.getElementById("specialCharCondition").className = specialCharCondition ? "valid-condition" : "invalid-condition";
// Show the conditions list when typing
if (password.length > 0) {
document.querySelector('.register').classList.add('show-conditions');
} else {
document.querySelector('.register').classList.remove('show-conditions');
}
});
</script>
<script>
const navbar = document.querySelector('.navbar'),
NavButton = document.querySelector('.nav-toggle-btn'),
open = document.querySelector('.open'),
close = document.querySelector('.close');
let count = 0;
NavButton.addEventListener('click', () => {
if (count === 0) {
navbar.classList.remove('nav_activated');
open.classList.add('close');
close.classList.add('open');
open.classList.remove('open');
close.classList.remove('close');
count++;
} else {
navbar.classList.add('nav_activated');
open.classList.add('open');
close.classList.add('close');
open.classList.remove('close');
close.classList.remove('open');
count = 0;
}
});
</script>
<script>
// Coordinates for the cursor
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");
// Colors for the circles
const colors = [
"#ffb56b", "#fdaf69", "#f89d63", "#f59761", "#ef865e", "#ec805d",
"#e36e5c", "#df685c", "#d5585c", "#d1525c", "#c5415d", "#c03b5d",
"#b22c5e", "#ac265e", "#9c155f", "#950f5f", "#830060", "#7c0060",
"#680060", "#60005f", "#48005f", "#3d005e"
];
// Assign colors and initial position to each circle
circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length];
});
// Update the coordinates when the mouse moves
window.addEventListener("mousemove", function (e) {
coords.x = e.clientX;
coords.y = e.clientY;
});
// Animation function to move the circles
function animateCircles() {
let x = coords.x;
let y = coords.y;
circles.forEach(function (circle, index) {
// Update the position and scale of each circle
circle.style.left = x - 12 + "px";
circle.style.top = y - 12 + "px";
circle.style.scale = (circles.length - index) / circles.length;
circle.x = x;
circle.y = y;
// Get the next circle in the sequence
const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});
// Repeat the animation
requestAnimationFrame(animateCircles);
}
// Start the animation
animateCircles();
</script>
</body>
</html>