-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSignUp.html
More file actions
775 lines (661 loc) Β· 29.1 KB
/
SignUp.html
File metadata and controls
775 lines (661 loc) Β· 29.1 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
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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TechRoute - Login & Signup</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #1e3a8a, #3b82f6);
color: #333;
line-height: 1.6;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
width: 100%;
max-width: 450px;
}
.logo-container {
text-align: center;
margin-bottom: 30px;
animation: fadeInDown 0.8s ease;
}
.logo {
width: 80px;
height: 80px;
background-color: white;
border-radius: 20%;
display: inline-flex;
justify-content: center;
align-items: center;
margin-bottom: 15px;
box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
overflow: hidden;
}
.logo img {
width: 110%;
height: 75%;
object-fit: cover;
}
.logo-title {
font-size: 20px;
font-weight: 700;
color: white;
letter-spacing: 1px;
}
.form-card {
background: white;
border-radius: 20px;
padding: 30px;
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
animation: slideUp 0.8s ease;
position: relative;
overflow: hidden;
}
.form-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 5px;
background: linear-gradient(to right, #1e3a8a, #3b82f6);
}
.tabs {
display: flex;
margin-bottom: 25px;
border-radius: 50px;
background: #f0f5ff;
padding: 5px;
}
.tab {
flex: 1;
text-align: center;
padding: 12px;
border-radius: 50px;
cursor: pointer;
font-weight: 500;
transition: all 0.3s ease;
}
.tab.active {
background: #007BFF;
color: white;
box-shadow: 0 3px 10px rgba(0, 123, 255, 0.3);
}
.form {
display: none;
}
.form.active {
display: block;
animation: fadeIn 0.5s ease;
}
.form-title {
text-align: center;
margin-bottom: 25px;
font-size: 24px;
color: #1e3a8a;
font-weight: 600;
}
.form-group {
margin-bottom: 20px;
}
.form-label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: #555;
}
.form-input {
width: 100%;
padding: 14px 18px;
border: 2px solid #e0e7ff;
border-radius: 12px;
font-size: 16px;
transition: all 0.3s ease;
font-family: 'Poppins', sans-serif;
}
.form-input:focus {
border-color: #007BFF;
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
outline: none;
}
.social-buttons {
display: flex;
flex-direction: column;
gap: 12px;
margin-bottom: 20px;
}
.social-btn {
display: flex;
align-items: center;
justify-content: center;
padding: 14px;
border-radius: 12px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
border: 2px solid #e0e7ff;
background: white;
color: #555;
}
.social-btn i {
margin-right: 10px;
font-size: 18px;
}
.social-btn.google:hover {
background: #f8f9ff;
border-color: #db4437;
color: #db4437;
}
.social-btn.facebook:hover {
background: #f8f9ff;
border-color: #4267B2;
color: #4267B2;
}
.social-btn.email:hover {
background: #f8f9ff;
border-color: #007BFF;
color: #007BFF;
}
.btn-primary {
width: 100%;
padding: 15px;
background: #007BFF;
color: white;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
margin-top: 10px;
font-family: 'Poppins', sans-serif;
}
.btn-primary:hover {
background: #0056b3;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}
.form-links {
text-align: center;
margin-top: 20px;
}
.link {
color: #007BFF;
text-decoration: none;
font-weight: 500;
transition: all 0.3s ease;
}
.link:hover {
text-decoration: underline;
}
.divider {
display: flex;
align-items: center;
margin: 25px 0;
color: #777;
}
.divider::before,
.divider::after {
content: '';
flex: 1;
height: 1px;
background: #e0e7ff;
}
.divider span {
padding: 0 15px;
font-size: 14px;
}
.password-strength {
height: 5px;
border-radius: 5px;
margin-top: 8px;
background: #e0e7ff;
overflow: hidden;
}
.password-strength-bar {
height: 100%;
width: 0;
border-radius: 5px;
transition: all 0.3s ease;
}
.strength-weak {
background: #ff4757;
width: 33%;
}
.strength-medium {
background: #ffa502;
width: 66%;
}
.strength-strong {
background: #2ed573;
width: 100%;
}
.password-hint {
font-size: 12px;
color: #777;
margin-top: 5px;
}
.error-message {
background: #ffe6e6;
color: #d63031;
padding: 12px;
border-radius: 8px;
margin: 15px 0;
border-left: 4px solid #d63031;
display: none;
}
.success-message {
background: #e6ffe6;
color: #00b894;
padding: 12px;
border-radius: 8px;
margin: 15px 0;
border-left: 4px solid #00b894;
display: none;
}
.loading {
opacity: 0.7;
pointer-events: none;
}
.loading::after {
content: '...';
animation: loading 1.5s infinite;
}
@keyframes loading {
0%, 33% { content: '.'; }
34%, 66% { content: '..'; }
67%, 100% { content: '...'; }
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fadeInDown {
from { opacity: 0; transform: translateY(-20px); }
to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 480px) {
.container { max-width: 100%; }
.form-card { padding: 18px 20px; }
.logo-title { font-size: 18px; }
.form-title { font-size: 22px; }
}
</style>
</head>
<body>
<div class="container">
<div class="logo-container">
<div class="logo">
<img src="images/techroute.png" alt="TechRoute Logo">
</div>
<div class="logo-title">TechRoute</div>
</div>
<div class="form-card">
<!-- Error and Success Messages -->
<div class="error-message" id="error-message"></div>
<div class="success-message" id="success-message"></div>
<div class="tabs">
<div class="tab active" data-tab="login">Login</div>
<div class="tab" data-tab="signup">Sign Up</div>
</div>
<!-- Login Form -->
<form class="form active" id="login-form">
<h2 class="form-title">Welcome Back</h2>
<div class="social-buttons">
<button type="button" class="social-btn google" id="google-login-btn">
<i class="fab fa-google"></i> Continue with Google
</button>
<button type="button" class="social-btn facebook" id="facebook-login-btn">
<i class="fab fa-facebook-f"></i> Continue with Facebook
</button>
<button type="button" class="social-btn email" id="email-login-btn">
<i class="fas fa-envelope"></i> Continue with Email
</button>
</div>
<div class="divider">
<span>Or</span>
</div>
<div class="email-fields" id="email-login-fields" style="display: none;">
<div class="form-group">
<label class="form-label" for="login-email">Email Address</label>
<input type="email" id="login-email" class="form-input" placeholder="Enter your email" required>
</div>
<div class="form-group">
<label class="form-label" for="login-password">Password</label>
<input type="password" id="login-password" class="form-input" placeholder="Enter your password" required>
</div>
<button type="submit" class="btn-primary" id="login-submit-btn">Login</button>
</div>
<div class="form-links">
<a href="#" class="link">Forgot Password?</a>
<p style="margin-top: 15px;">Don't have an account? <a href="#" class="link" id="switch-to-signup">Create one</a></p>
</div>
</form>
<!-- Signup Form -->
<form class="form" id="signup-form">
<h2 class="form-title">Create Account</h2>
<div class="form-group">
<label class="form-label" for="signup-name">Full Name</label>
<input type="text" id="signup-name" class="form-input" placeholder="Enter your full name" required>
</div>
<div class="form-group">
<label class="form-label" for="signup-email">Email Address</label>
<input type="email" id="signup-email" class="form-input" placeholder="Enter your email" required>
</div>
<div class="form-group">
<label class="form-label" for="signup-password">Password</label>
<input type="password" id="signup-password" class="form-input" placeholder="Create a password (min. 6 characters)" required>
<div class="password-strength">
<div class="password-strength-bar" id="password-strength-bar"></div>
</div>
<div class="password-hint" id="password-hint">Use 6+ characters with a mix of letters, numbers & symbols</div>
</div>
<div class="form-group">
<label class="form-label" for="signup-confirm-password">Confirm Password</label>
<input type="password" id="signup-confirm-password" class="form-input" placeholder="Confirm your password" required>
<div class="password-hint" id="confirm-password-hint"></div>
</div>
<button type="submit" class="btn-primary" id="signup-submit-btn">Create Account</button>
<div class="form-links">
<p style="margin-top: 15px;">Already have an account? <a href="#" class="link" id="switch-to-login">Login</a></p>
</div>
</form>
</div>
</div>
<!-- Firebase SDK - FIXED VERSION -->
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-app.js";
import {
getAuth,
createUserWithEmailAndPassword,
signInWithEmailAndPassword,
GoogleAuthProvider,
FacebookAuthProvider,
signInWithPopup,
updateProfile
} from "https://www.gstatic.com/firebasejs/10.14.0/firebase-auth.js";
console.log('π STARTING FIREBASE - FIXED VERSION...');
// Firebase configuration - UPDATED
const firebaseConfig = {
apiKey: "AIzaSyDB8NztWfn5TPQio3z0ycr2i8HmtqXlly8",
authDomain: "techroute-app.firebaseapp.com",
projectId: "techroute-app",
storageBucket: "techroute-app.firebasestorage.app",
messagingSenderId: "9216813599",
appId: "1:9216813599:web:09d001782de84a48dbc32a",
measurementId: "G-V1J2SL6LHD"
};
console.log('π Firebase Config:', firebaseConfig);
try {
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
// IMPORTANT: Set persistence to fix invalid-credential
auth.useDeviceLanguage();
console.log('β
Firebase initialized successfully!');
// Configure Google Provider
const googleProvider = new GoogleAuthProvider();
googleProvider.setCustomParameters({
prompt: 'select_account'
});
// Configure Facebook Provider
const facebookProvider = new FacebookAuthProvider();
// Enhanced error handler for invalid-credential
function handleAuthError(error, context) {
console.error(`β ${context} ERROR:`, error);
console.log('π Error code:', error.code);
console.log('π Error message:', error.message);
const errorMap = {
'auth/invalid-credential': 'β Invalid login credentials. Please try signing up first or check your email/password.',
'auth/invalid-email': 'β Please enter a valid email address',
'auth/user-disabled': 'β This account has been disabled',
'auth/user-not-found': 'β No account found. Please sign up first.',
'auth/wrong-password': 'β Incorrect password',
'auth/email-already-in-use': 'β An account with this email already exists',
'auth/weak-password': 'β Password should be at least 6 characters',
'auth/popup-blocked': 'β Popup was blocked. Please allow popups.',
'auth/network-request-failed': 'β Network error. Check your internet.',
'auth/operation-not-allowed': 'β Email/password accounts are not enabled in Firebase Console.',
'auth/unauthorized-domain': `β Domain not authorized. Add ${window.location.hostname} to Firebase.`
};
const friendlyMessage = errorMap[error.code] || `β Authentication failed: ${error.code}`;
showMessage('error-message', friendlyMessage);
// Special handling for invalid-credential
if (error.code === 'auth/invalid-credential') {
console.log('π‘ TIP: Try signing up first, or use test@test.com / 123456');
}
}
// UI Functions
function showMessage(elementId, message, isError = true) {
const element = document.getElementById(elementId);
element.textContent = message;
element.style.display = 'block';
if (isError) {
element.className = 'error-message';
} else {
element.className = 'success-message';
}
setTimeout(() => {
element.style.display = 'none';
}, 5000);
}
function setLoading(button, isLoading) {
if (isLoading) {
button.classList.add('loading');
button.disabled = true;
} else {
button.classList.remove('loading');
button.disabled = false;
}
}
function redirectToCareerPaths() {
console.log('π Redirecting to CareerPaths.html...');
window.location.href = "CareerPaths.html";
}
// SIGNUP FIRST - Then login
document.getElementById('signup-form').addEventListener('submit', async (e) => {
e.preventDefault();
const name = document.getElementById('signup-name').value;
const email = document.getElementById('signup-email').value;
const password = document.getElementById('signup-password').value;
const confirmPassword = document.getElementById('signup-confirm-password').value;
const submitBtn = document.getElementById('signup-submit-btn');
console.log('π Starting email signup...', { name, email });
if (!name || !email || !password || !confirmPassword) {
showMessage('error-message', 'β Please fill in all fields');
return;
}
if (password !== confirmPassword) {
showMessage('error-message', "β Passwords do not match");
return;
}
if (password.length < 6) {
showMessage('error-message', "β Password should be at least 6 characters long");
return;
}
setLoading(submitBtn, true);
try {
console.log('π Creating user account...');
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
console.log('β
Email signup successful!', userCredential.user);
// Update profile with display name
await updateProfile(userCredential.user, {
displayName: name
});
showMessage('success-message', `π Account created successfully for ${name}!`, false);
setTimeout(redirectToCareerPaths, 1500);
} catch (error) {
console.error('β Email signup failed!');
handleAuthError(error, 'Email Signup');
} finally {
setLoading(submitBtn, false);
}
});
// LOGIN - Only after signing up
document.getElementById('login-form').addEventListener('submit', async (e) => {
e.preventDefault();
const email = document.getElementById('login-email').value;
const password = document.getElementById('login-password').value;
const submitBtn = document.getElementById('login-submit-btn');
console.log('π Starting email login...', { email });
if (!email || !password) {
showMessage('error-message', 'β Please fill in all fields');
return;
}
setLoading(submitBtn, true);
try {
console.log('π Attempting login...');
const userCredential = await signInWithEmailAndPassword(auth, email, password);
console.log('β
Email login successful!', userCredential.user);
showMessage('success-message', `π Welcome back, ${userCredential.user.email}!`, false);
setTimeout(redirectToCareerPaths, 1500);
} catch (error) {
console.error('β Email login failed!');
// Special suggestion for invalid-credential
if (error.code === 'auth/invalid-credential') {
showMessage('error-message', 'β No account found with these credentials. Please sign up first or use: test@test.com / 123456');
} else {
handleAuthError(error, 'Email Login');
}
} finally {
setLoading(submitBtn, false);
}
});
// Google Authentication
document.getElementById('google-login-btn').addEventListener('click', async () => {
const btn = document.getElementById('google-login-btn');
console.log('π Starting Google authentication...');
setLoading(btn, true);
try {
console.log('π Calling Google sign-in...');
const result = await signInWithPopup(auth, googleProvider);
console.log('β
Google authentication successful!', result.user);
showMessage('success-message', `π Welcome, ${result.user.displayName || result.user.email}!`, false);
setTimeout(redirectToCareerPaths, 1500);
} catch (error) {
console.error('β Google authentication failed!');
handleAuthError(error, 'Google Authentication');
} finally {
setLoading(btn, false);
}
});
// Facebook Authentication
document.getElementById('facebook-login-btn').addEventListener('click', async () => {
const btn = document.getElementById('facebook-login-btn');
console.log('π Starting Facebook authentication...');
setLoading(btn, true);
try {
console.log('π Calling Facebook sign-in...');
const result = await signInWithPopup(auth, facebookProvider);
console.log('β
Facebook authentication successful!', result.user);
showMessage('success-message', `π Welcome, ${result.user.displayName || result.user.email}!`, false);
setTimeout(redirectToCareerPaths, 1500);
} catch (error) {
console.error('β Facebook authentication failed!');
handleAuthError(error, 'Facebook Authentication');
} finally {
setLoading(btn, false);
}
});
} catch (error) {
console.error('π₯ FIREBASE INITIALIZATION FAILED:', error);
showMessage('error-message', `β Firebase failed to initialize: ${error.message}`);
}
</script>
<script>
// Tab switching functionality
document.addEventListener('DOMContentLoaded', function() {
const tabs = document.querySelectorAll('.tab');
const forms = document.querySelectorAll('.form');
tabs.forEach(tab => {
tab.addEventListener('click', function() {
const targetTab = this.getAttribute('data-tab');
// Update active tab
tabs.forEach(t => t.classList.remove('active'));
this.classList.add('active');
// Show corresponding form
forms.forEach(form => {
form.classList.remove('active');
if (form.id === `${targetTab}-form`) {
form.classList.add('active');
}
});
});
});
// Switch between login and signup links
document.getElementById('switch-to-signup').addEventListener('click', function(e) {
e.preventDefault();
document.querySelector('.tab[data-tab="signup"]').click();
});
document.getElementById('switch-to-login').addEventListener('click', function(e) {
e.preventDefault();
document.querySelector('.tab[data-tab="login"]').click();
});
// Email field toggles
document.getElementById('email-login-btn').addEventListener('click', function() {
const emailFields = document.getElementById('email-login-fields');
emailFields.style.display = emailFields.style.display === 'none' ? 'block' : 'none';
});
// Password strength indicator
const passwordInput = document.getElementById('signup-password');
const passwordStrengthBar = document.getElementById('password-strength-bar');
const passwordHint = document.getElementById('password-hint');
passwordInput.addEventListener('input', function() {
const password = this.value;
let strength = 0;
if (password.length >= 6) strength += 1;
if (password.match(/[a-z]/) && password.match(/[A-Z]/)) strength += 1;
if (password.match(/\d/)) strength += 1;
if (password.match(/[^a-zA-Z\d]/)) strength += 1;
// Update strength bar
passwordStrengthBar.className = 'password-strength-bar';
if (password.length === 0) {
passwordHint.textContent = 'Use 6+ characters with a mix of letters, numbers & symbols';
} else if (strength <= 1) {
passwordStrengthBar.classList.add('strength-weak');
passwordHint.textContent = 'Weak password - try adding uppercase letters, numbers, or symbols';
} else if (strength <= 2) {
passwordStrengthBar.classList.add('strength-medium');
passwordHint.textContent = 'Medium password - could be stronger';
} else {
passwordStrengthBar.classList.add('strength-strong');
passwordHint.textContent = 'Strong password!';
}
});
// Password confirmation check
const confirmPasswordInput = document.getElementById('signup-confirm-password');
const confirmPasswordHint = document.getElementById('confirm-password-hint');
confirmPasswordInput.addEventListener('input', function() {
const password = passwordInput.value;
const confirmPassword = this.value;
if (confirmPassword.length === 0) {
confirmPasswordHint.textContent = '';
} else if (password === confirmPassword) {
confirmPasswordHint.textContent = 'Passwords match!';
confirmPasswordHint.style.color = '#2ed573';
} else {
confirmPasswordHint.textContent = 'Passwords do not match';
confirmPasswordHint.style.color = '#ff4757';
}
});
});
</script>
</body>
</html>