-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword-protect.html
More file actions
executable file
·175 lines (166 loc) · 5.57 KB
/
password-protect.html
File metadata and controls
executable file
·175 lines (166 loc) · 5.57 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Access Required - NASA Disasters Documentation</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-container {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
max-width: 400px;
width: 90%;
}
.logo {
text-align: center;
margin-bottom: 30px;
}
.logo img {
max-width: 200px;
height: auto;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 10px;
font-size: 24px;
}
p {
text-align: center;
color: #666;
margin-bottom: 30px;
}
.input-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #555;
font-weight: 500;
}
input[type="password"] {
width: 100%;
padding: 12px;
border: 2px solid #ddd;
border-radius: 5px;
font-size: 16px;
box-sizing: border-box;
transition: border-color 0.3s;
}
input[type="password"]:focus {
outline: none;
border-color: #667eea;
}
button {
width: 100%;
padding: 12px;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
background: #5568d3;
}
.error {
color: #e74c3c;
text-align: center;
margin-top: 15px;
display: none;
}
.error.show {
display: block;
}
</style>
</head>
<body>
<div class="login-container">
<div class="logo">
<img src="logo/disasters_logo.png" alt="NASA Disasters" onerror="this.style.display='none'">
</div>
<h1>Access Required</h1>
<p>Please enter the password to access the NASA Disasters Documentation</p>
<form id="loginForm">
<div class="input-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="Enter password" required autofocus>
</div>
<button type="submit">Access Documentation</button>
<div class="error" id="error">Incorrect password. Please try again.</div>
</form>
</div>
<script>
// Configuration - password will be injected during build
const CORRECT_PASSWORD = '{{SITE_PASSWORD}}'; // This will be replaced during GitHub Actions build
const SESSION_KEY = 'disasters_docs_auth';
const SESSION_DURATION = 8 * 60 * 60 * 1000; // 8 hours in milliseconds
// Check if already authenticated
function checkExistingAuth() {
const auth = localStorage.getItem(SESSION_KEY);
if (auth) {
try {
const authData = JSON.parse(auth);
const now = new Date().getTime();
if (authData.expires > now && authData.authenticated) {
// Valid session, redirect to actual site
window.location.href = 'index.html';
return true;
} else {
// Expired or invalid, clear it
localStorage.removeItem(SESSION_KEY);
}
} catch (e) {
localStorage.removeItem(SESSION_KEY);
}
}
return false;
}
// Handle form submission
document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();
const password = document.getElementById('password').value;
const errorDiv = document.getElementById('error');
const button = document.querySelector('button');
// Disable button during check
button.disabled = true;
button.textContent = 'Checking...';
if (password === CORRECT_PASSWORD) {
// Correct password
const expires = new Date().getTime() + SESSION_DURATION;
localStorage.setItem(SESSION_KEY, JSON.stringify({
authenticated: true,
expires: expires
}));
window.location.href = 'index.html';
} else {
// Wrong password
errorDiv.classList.add('show');
document.getElementById('password').value = '';
button.disabled = false;
button.textContent = 'Access Documentation';
// Hide error after 3 seconds
setTimeout(() => {
errorDiv.classList.remove('show');
}, 3000);
}
});
// Check on page load
checkExistingAuth();
</script>
</body>
</html>