-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.js
More file actions
24 lines (20 loc) · 864 Bytes
/
admin.js
File metadata and controls
24 lines (20 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Hardcoded credentials (can later move to server-side or hash in storage)
const ADMIN_USERNAME = 'admin';
const ADMIN_PASSWORD = 'admin123';
function handleLogin(event) {
event.preventDefault();
const username = document.getElementById('username').value.trim();
const password = document.getElementById('password').value.trim();
const errorBox = document.getElementById('loginError');
if (username === ADMIN_USERNAME && password === ADMIN_PASSWORD) {
localStorage.setItem('isAdminLoggedIn', 'true');
window.location.href = 'create.html';
} else {
errorBox.textContent = 'Invalid username or password';
errorBox.classList.remove('d-none');
}
}
// If already logged in, redirect to dashboard automatically
if (localStorage.getItem('isAdminLoggedIn') === 'true') {
window.location.href = 'create.html';
}