Spaces:
Running
Running
how can I login
Browse files- index.html +31 -4
index.html
CHANGED
|
@@ -351,12 +351,39 @@
|
|
| 351 |
<script>
|
| 352 |
feather.replace();
|
| 353 |
|
| 354 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
document.querySelector('form').addEventListener('submit', function(e) {
|
| 356 |
e.preventDefault();
|
| 357 |
-
|
| 358 |
-
document.getElementById('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
});
|
| 360 |
-
|
| 361 |
</body>
|
| 362 |
</html>
|
|
|
|
| 351 |
<script>
|
| 352 |
feather.replace();
|
| 353 |
|
| 354 |
+
// Sample users database (in a real app, this would be server-side)
|
| 355 |
+
const users = [
|
| 356 |
+
{ email: 'admin@example.com', password: 'admin123', role: 'admin', name: 'Admin User' },
|
| 357 |
+
{ email: 'employee@example.com', password: 'employee123', role: 'employee', name: 'John Doe' }
|
| 358 |
+
];
|
| 359 |
+
|
| 360 |
document.querySelector('form').addEventListener('submit', function(e) {
|
| 361 |
e.preventDefault();
|
| 362 |
+
|
| 363 |
+
const email = document.getElementById('email').value;
|
| 364 |
+
const password = document.getElementById('password').value;
|
| 365 |
+
|
| 366 |
+
// Find user
|
| 367 |
+
const user = users.find(u => u.email === email && u.password === password);
|
| 368 |
+
|
| 369 |
+
if (user) {
|
| 370 |
+
// Hide auth page
|
| 371 |
+
document.getElementById('auth-page').classList.add('hidden');
|
| 372 |
+
|
| 373 |
+
// Show appropriate dashboard
|
| 374 |
+
if (user.role === 'admin') {
|
| 375 |
+
document.getElementById('admin-dashboard').classList.remove('hidden');
|
| 376 |
+
// Update admin name in sidebar
|
| 377 |
+
document.querySelector('#admin-dashboard .sidebar-link.active + div p').textContent = user.name;
|
| 378 |
+
} else {
|
| 379 |
+
document.getElementById('employee-dashboard').classList.remove('hidden');
|
| 380 |
+
// Update employee name in sidebar
|
| 381 |
+
document.querySelector('#employee-dashboard .sidebar-link.active + div p').textContent = user.name;
|
| 382 |
+
}
|
| 383 |
+
} else {
|
| 384 |
+
alert('Invalid email or password');
|
| 385 |
+
}
|
| 386 |
});
|
| 387 |
+
</script>
|
| 388 |
</body>
|
| 389 |
</html>
|