-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
109 lines (102 loc) · 4.47 KB
/
Copy pathindex.html
File metadata and controls
109 lines (102 loc) · 4.47 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>EduHub Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles-login.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
</head>
<body>
<div class="centered-container">
<div class="glass-box">
<div class="product-header">
<span class="product-logo"><i class="fas fa-graduation-cap"></i></span>
<span class="product-title">EduHub</span>
<span class="product-slogan">Empowering minds, shaping futures</span>
</div>
<div class="box-contents">
<div class="welcome">Welcome</div>
<div class="welcome-sub">Sign up or Login to continue your learning journey</div>
<div class="tab-switch">
<button class="tab-btn active" id="studentBtn" type="button">
<i class="fas fa-user-graduate"></i> Student
</button>
<button class="tab-btn" id="professorBtn" type="button">
<i class="fas fa-chalkboard-teacher"></i> Professor
</button>
</div>
<form class="login-form" autocomplete="off">
<div class="input-wrap">
<span class="input-icon"><i class="fas fa-envelope"></i></span>
<input type="email" class="login-input" placeholder="Email Address" required autocomplete="username" id="email">
</div>
<div class="input-wrap">
<span class="input-icon"><i class="fas fa-lock"></i></span>
<input type="password" class="login-input" placeholder="Password" required autocomplete="current-password" id="password">
<button type="button" class="input-eye" id="togglePassword" tabindex="0">
<i class="fas fa-eye"></i>
</button>
</div>
<div class="options-row">
<label class="remember-wrap">
<input type="checkbox" class="remember-input"> Remember me
</label>
</div>
<div class="button-group">
<button class="login-btn" type="button">Sign Up</button>
<button class="login-btn" type="submit">Login</button>
</div>
</form>
</div>
</div>
</div>
<!--Standalone java document wasn't working, try any fix you know-->
<script src="script-login.js"></script>
<!-- Include Firebase SDKs -->
<script type="module">
// Include Firebase SDKs
import { initializeApp } from "https://www.gstatic.com/firebasejs/12.3.0/firebase-app.js";
import { getAuth, signInWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/12.3.0/firebase-auth.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyAAYpr26AUD3Vi6QAlIrXWLsGRUwytJbOg",
authDomain: "smartboard-and-attendance.firebaseapp.com",
databaseURL: "https://smartboard-and-attendance-default-rtdb.asia-southeast1.firebasedatabase.app",
projectId: "smartboard-and-attendance",
storageBucket: "smartboard-and-attendance.firebasestorage.app",
messagingSenderId: "750785617807",
appId: "1:750785617807:web:f83055cca5cad6debcb5fa"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(); // Get the auth instance correctly
// 🔹 Handle login button click
function login() {
const email = document.getElementById("email").value; // Corrected reference to the email field
const password = document.getElementById("password").value;
signInWithEmailAndPassword(auth, email, password) // Correctly using the Firebase auth method
.then((userCredential) => {
// ✅ Login success
console.log("Login Successful! 🎉");
// Redirect after login based on email domain
if (email.endsWith("@student.com")) {
window.location.href = "studenthome.html";
} else if (email.endsWith("@professor.com")) {
window.location.href = "profhome.html";
}
})
.catch((error) => {
// ❌ Login failed
alert("Error: " + error.message);
});
}
// Handle form submission and navigate to the correct page.
document.querySelector(".login-form").onsubmit = (e) => {
e.preventDefault(); // Prevent form submission
login(); // Call the login function
};
</script>
</body>
</html>