-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreset-password.html
More file actions
221 lines (197 loc) · 10.4 KB
/
reset-password.html
File metadata and controls
221 lines (197 loc) · 10.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script>if(location.search.includes('internal=1'))localStorage.setItem('_cf_internal','1');if(localStorage.getItem('_cf_internal')==='1')Object.defineProperty(window,'__cfBeacon',{get:()=>false,set:()=>{}});</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title data-i18n="reset_page_title">Reset Password - Readmigo</title>
<meta name="description" content="Reset your Readmigo password">
<link rel="icon" type="image/x-icon" href="/assets/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#6366f1',
secondary: '#8b5cf6',
}
}
}
}
</script>
<style>
.text-gradient {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
</style>
<script src="js/posthog.js"></script>
<script src="js/tracking.js"></script>
</head>
<body class="bg-gray-50 text-gray-900 antialiased min-h-screen flex flex-col">
<header class="bg-white border-b border-gray-100">
<nav class="max-w-6xl mx-auto px-6 py-4 flex items-center justify-between">
<a href="/" class="text-2xl font-bold text-gradient">Readmigo</a>
</nav>
</header>
<main class="flex-1 flex items-center justify-center px-6 py-12">
<div class="w-full max-w-md">
<div id="form-container" class="bg-white rounded-2xl shadow-lg p-8">
<h1 class="text-2xl font-bold text-center mb-2" data-i18n="reset_h1">Reset Password</h1>
<p class="text-gray-600 text-center mb-8" data-i18n="reset_subtitle">Enter your new password below</p>
<form id="reset-form" class="space-y-6">
<div>
<label for="password" class="block text-sm font-medium text-gray-700 mb-2" data-i18n="reset_label_new">New Password</label>
<input
type="password"
id="password"
name="password"
required
minlength="8"
maxlength="72"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition"
placeholder="At least 8 characters"
>
</div>
<div>
<label for="confirm-password" class="block text-sm font-medium text-gray-700 mb-2" data-i18n="reset_label_confirm">Confirm Password</label>
<input
type="password"
id="confirm-password"
name="confirm-password"
required
minlength="8"
maxlength="72"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition"
placeholder="Re-enter your password"
>
</div>
<div id="error-message" class="hidden text-red-600 text-sm text-center"></div>
<button
type="submit"
id="submit-btn"
data-i18n="reset_btn"
class="w-full bg-primary text-white py-3 rounded-lg font-semibold hover:bg-primary/90 transition disabled:opacity-50 disabled:cursor-not-allowed"
>
Reset Password
</button>
</form>
</div>
<div id="success-container" class="hidden bg-white rounded-2xl shadow-lg p-8 text-center">
<div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
<svg class="w-8 h-8 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
</div>
<h2 class="text-2xl font-bold mb-2" data-i18n="reset_success_h2">Password Reset!</h2>
<p class="text-gray-600 mb-6" data-i18n="reset_success_p">Your password has been successfully reset. You can now log in with your new password.</p>
<a href="/" class="inline-block bg-primary text-white px-6 py-3 rounded-lg font-semibold hover:bg-primary/90 transition" data-i18n="reset_back_home">
Back to Home
</a>
</div>
<div id="invalid-token-container" class="hidden bg-white rounded-2xl shadow-lg p-8 text-center">
<div class="w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4">
<svg class="w-8 h-8 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</div>
<h2 class="text-2xl font-bold mb-2" data-i18n="reset_invalid_h2">Invalid Link</h2>
<p class="text-gray-600 mb-6" data-i18n="reset_invalid_p">This password reset link is invalid or has expired. Please request a new password reset.</p>
<a href="/" class="inline-block bg-primary text-white px-6 py-3 rounded-lg font-semibold hover:bg-primary/90 transition" data-i18n="reset_back_home">
Back to Home
</a>
</div>
</div>
</main>
<footer class="py-6 text-center text-gray-500 text-sm">
<p data-i18n="footer_rights">© 2026 Readmigo. All rights reserved.</p>
</footer>
<!-- Hidden i18n spans for JS-generated messages -->
<span class="hidden" data-i18n="reset_submitting">Resetting...</span>
<span class="hidden" data-i18n="reset_err_mismatch">Passwords do not match</span>
<span class="hidden" data-i18n="reset_err_length">Password must be at least 8 characters</span>
<span class="hidden" data-i18n="reset_err_failed">Failed to reset password. Please try again.</span>
<span class="hidden" data-i18n="reset_err_network">Network error. Please check your connection and try again.</span>
<script src="/js/i18n.js"></script>
<script>
// Helper to read translated text from data-i18n elements
function getT(key) {
var el = document.querySelector('[data-i18n="' + key + '"]');
return el ? el.textContent : key;
}
// Update input placeholders after i18n applies
document.getElementById('password').placeholder = getT('reset_placeholder_new');
document.getElementById('confirm-password').placeholder = getT('reset_placeholder_confirm');
</script>
<script>
const API_BASE = 'https://readmigo-api.fly.dev/api/v1';
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('token');
const formContainer = document.getElementById('form-container');
const successContainer = document.getElementById('success-container');
const invalidTokenContainer = document.getElementById('invalid-token-container');
const resetForm = document.getElementById('reset-form');
const errorMessage = document.getElementById('error-message');
const submitBtn = document.getElementById('submit-btn');
const passwordInput = document.getElementById('password');
const confirmPasswordInput = document.getElementById('confirm-password');
if (!token) {
formContainer.classList.add('hidden');
invalidTokenContainer.classList.remove('hidden');
}
resetForm.addEventListener('submit', async (e) => {
e.preventDefault();
const password = passwordInput.value;
const confirmPassword = confirmPasswordInput.value;
errorMessage.classList.add('hidden');
if (password !== confirmPassword) {
errorMessage.textContent = getT('reset_err_mismatch');
errorMessage.classList.remove('hidden');
return;
}
if (password.length < 8) {
errorMessage.textContent = getT('reset_err_length');
errorMessage.classList.remove('hidden');
return;
}
submitBtn.disabled = true;
submitBtn.textContent = getT('reset_submitting');
try {
const response = await fetch(`${API_BASE}/auth/reset-password`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
token: token,
newPassword: password,
}),
});
const data = await response.json();
if (response.ok && data.success) {
formContainer.classList.add('hidden');
successContainer.classList.remove('hidden');
} else {
if (data.message && data.message.includes('expired')) {
formContainer.classList.add('hidden');
invalidTokenContainer.classList.remove('hidden');
} else {
errorMessage.textContent = data.message || getT('reset_err_failed');
errorMessage.classList.remove('hidden');
submitBtn.disabled = false;
submitBtn.textContent = getT('reset_btn');
}
}
} catch (error) {
errorMessage.textContent = getT('reset_err_network');
errorMessage.classList.remove('hidden');
submitBtn.disabled = false;
submitBtn.textContent = getT('reset_btn');
}
});
</script>
</body>
</html>