-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfix-email-confirmation.html
More file actions
334 lines (308 loc) Β· 10.4 KB
/
fix-email-confirmation.html
File metadata and controls
334 lines (308 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fix Email Confirmation Issue</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1000px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.container {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.section {
margin: 20px 0;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
}
.success {
background-color: #d4edda;
border-color: #c3e6cb;
color: #155724;
}
.error {
background-color: #f8d7da;
border-color: #f5c6cb;
color: #721c24;
}
.warning {
background-color: #fff3cd;
border-color: #ffeaa7;
color: #856404;
}
.info {
background-color: #d1ecf1;
border-color: #bee5eb;
color: #0c5460;
}
button {
background-color: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
button:hover {
background-color: #0056b3;
}
button:disabled {
background-color: #6c757d;
cursor: not-allowed;
}
.log {
background-color: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 5px;
padding: 10px;
margin: 10px 0;
font-family: monospace;
font-size: 12px;
max-height: 300px;
overflow-y: auto;
}
input {
width: 100%;
padding: 8px;
margin: 5px 0;
border: 1px solid #ddd;
border-radius: 4px;
}
.solution {
background-color: #e8f5e8;
border-left: 4px solid #28a745;
padding: 15px;
margin: 10px 0;
}
.code {
background-color: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 4px;
padding: 10px;
font-family: monospace;
font-size: 12px;
margin: 10px 0;
}
</style>
</head>
<body>
<div class="container">
<h1>π§ Fix Email Confirmation Issue</h1>
<p>
This tool helps fix the email confirmation issue where confirmation
emails aren't being sent.
</p>
<div class="section info">
<h3>π The Problem</h3>
<p>You're experiencing an issue where:</p>
<ul>
<li>β
Password reset emails work fine</li>
<li>β Email confirmation emails are not being sent</li>
<li>β Users can't log in because their email isn't confirmed</li>
</ul>
<p>
This is likely due to Supabase email configuration or the way we're
calling the resend function.
</p>
</div>
<div class="section">
<h3>π Step 1: Test Current Email Functions</h3>
<form id="test-form">
<input
type="email"
id="test-email"
placeholder="Enter your email address"
required
/>
<button type="button" onclick="testPasswordReset()">
Test Password Reset Email
</button>
<button type="button" onclick="testConfirmationEmail()">
Test Confirmation Email
</button>
</form>
<div id="test-results"></div>
</div>
<div class="section">
<h3>π οΈ Step 2: Manual Email Confirmation</h3>
<p>
If confirmation emails aren't working, you can manually confirm your
email using one of these methods:
</p>
<div class="solution">
<h4>Method 1: Use Password Reset (Recommended)</h4>
<p>
Since password reset emails work, use this to confirm your email:
</p>
<ol>
<li>Click "Test Password Reset Email" above</li>
<li>Check your email for the reset link</li>
<li>Click the reset link (this confirms your email)</li>
<li>Set a new password</li>
<li>Try logging in with your new password</li>
</ol>
</div>
<div class="solution">
<h4>Method 2: Direct Supabase Admin</h4>
<p>If you have access to your Supabase dashboard:</p>
<ol>
<li>Go to your Supabase project dashboard</li>
<li>Navigate to Authentication β Users</li>
<li>Find your user account</li>
<li>Click on the user</li>
<li>Click "Confirm user" button</li>
</ol>
</div>
<div class="solution">
<h4>Method 3: SQL Command</h4>
<p>If you have database access, run this SQL command:</p>
<div class="code">
UPDATE auth.users SET email_confirmed_at = NOW() WHERE email =
'your-email@example.com';
</div>
</div>
</div>
<div class="section">
<h3>π§ Step 3: Fix the Code Issue</h3>
<p>
The issue might be in how we're calling the resend function. Here's
the fix:
</p>
<div class="code">
// In AuthContext.tsx, the resendConfirmation function should be:
const resendConfirmation = useCallback( async (email: string):
Promise<void> => { try { setIsLoading(true); clearError(); //
Use the correct Supabase method const { error } = await
supabase.auth.resend({ type: 'signup', email: email, options: {
emailRedirectTo:
`${window.location.origin}/auth/callback?type=signup`, }, }); if
(error) { throw error; } } catch (error) { handleError(error, "Failed
to resend confirmation email. Please try again."); throw error; }
finally { setIsLoading(false); } }, [handleError, clearError] );
</div>
</div>
<div class="section">
<h3>π§ Step 4: Check Supabase Email Settings</h3>
<p>Make sure your Supabase project has email configured:</p>
<ol>
<li>Go to your Supabase project dashboard</li>
<li>Navigate to Authentication β Settings</li>
<li>Check "Enable email confirmations" is enabled</li>
<li>Verify your email templates are configured</li>
<li>Check that your domain is allowed for redirects</li>
</ol>
</div>
<div class="section">
<h3>π Diagnostic Logs</h3>
<button onclick="clearLogs()">Clear Logs</button>
<div id="logs" class="log"></div>
</div>
</div>
<script type="module">
import { createClient } from "https://cdn.skypack.dev/@supabase/supabase-js@2";
const supabaseUrl = "https://cikihoznjxwhwqmnifvy.supabase.co/";
const supabaseKey =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNpa2lob3puanh3aHdxbW5pZnZ5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjA2OTEyMDksImV4cCI6MjA3NjI2NzIwOX0.C4ED1keyxTUFULpI2zoUIBi-GtZTpBXhFTXXPM8MtQ8";
const supabase = createClient(supabaseUrl, supabaseKey);
function log(message, type = "info") {
const logsDiv = document.getElementById("logs");
const timestamp = new Date().toLocaleTimeString();
const logEntry = document.createElement("div");
logEntry.innerHTML = `[${timestamp}] ${message}`;
logEntry.style.color =
type === "error"
? "red"
: type === "success"
? "green"
: type === "warning"
? "orange"
: "black";
logsDiv.appendChild(logEntry);
logsDiv.scrollTop = logsDiv.scrollHeight;
}
window.testPasswordReset = async function () {
const email = document.getElementById("test-email").value;
const resultsDiv = document.getElementById("test-results");
if (!email) {
alert("Please enter an email address first");
return;
}
try {
log(`Testing password reset email for: ${email}`);
const { error } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo: `${window.location.origin}/reset-password`,
});
if (error) {
throw error;
}
resultsDiv.innerHTML = `
<div class="success">
β
Password reset email sent successfully!<br>
Check your email inbox and spam folder.
</div>
`;
log("Password reset email sent successfully", "success");
} catch (error) {
resultsDiv.innerHTML = `
<div class="error">
β Password reset failed: ${error.message}
</div>
`;
log(`Password reset failed: ${error.message}`, "error");
}
};
window.testConfirmationEmail = async function () {
const email = document.getElementById("test-email").value;
const resultsDiv = document.getElementById("test-results");
if (!email) {
alert("Please enter an email address first");
return;
}
try {
log(`Testing confirmation email for: ${email}`);
const { error } = await supabase.auth.resend({
type: "signup",
email: email,
options: {
emailRedirectTo: `${window.location.origin}/auth/callback?type=signup`,
},
});
if (error) {
throw error;
}
resultsDiv.innerHTML = `
<div class="success">
β
Confirmation email sent successfully!<br>
Check your email inbox and spam folder.
</div>
`;
log("Confirmation email sent successfully", "success");
} catch (error) {
resultsDiv.innerHTML = `
<div class="error">
β Confirmation email failed: ${error.message}<br>
<strong>This is the issue we need to fix!</strong>
</div>
`;
log(`Confirmation email failed: ${error.message}`, "error");
}
};
window.clearLogs = function () {
document.getElementById("logs").innerHTML = "";
};
// Initialize
log("Email Confirmation Fix Tool initialized");
log("Ready to test and fix email confirmation issues...");
</script>
</body>
</html>