Create reset.html
Browse files- reset.html +129 -0
reset.html
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>Reset Password</title>
|
| 7 |
+
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
|
| 8 |
+
<style>
|
| 9 |
+
body {
|
| 10 |
+
font-family: system-ui, sans-serif;
|
| 11 |
+
display: flex;
|
| 12 |
+
flex-direction: column;
|
| 13 |
+
align-items: center;
|
| 14 |
+
justify-content: center;
|
| 15 |
+
min-height: 100vh;
|
| 16 |
+
background: #f5f5f5;
|
| 17 |
+
color: #333;
|
| 18 |
+
margin: 0;
|
| 19 |
+
}
|
| 20 |
+
.card {
|
| 21 |
+
background: #fff;
|
| 22 |
+
padding: 2rem;
|
| 23 |
+
border-radius: 1rem;
|
| 24 |
+
box-shadow: 0 2px 12px rgba(0,0,0,0.1);
|
| 25 |
+
max-width: 400px;
|
| 26 |
+
width: 90%;
|
| 27 |
+
}
|
| 28 |
+
h2 {
|
| 29 |
+
text-align: center;
|
| 30 |
+
margin-bottom: 1rem;
|
| 31 |
+
}
|
| 32 |
+
input {
|
| 33 |
+
width: 100%;
|
| 34 |
+
padding: 0.75rem;
|
| 35 |
+
border-radius: 0.5rem;
|
| 36 |
+
border: 1px solid #ccc;
|
| 37 |
+
margin-bottom: 1rem;
|
| 38 |
+
font-size: 1rem;
|
| 39 |
+
}
|
| 40 |
+
button {
|
| 41 |
+
width: 100%;
|
| 42 |
+
padding: 0.75rem;
|
| 43 |
+
border: none;
|
| 44 |
+
border-radius: 0.5rem;
|
| 45 |
+
background: #007aff;
|
| 46 |
+
color: white;
|
| 47 |
+
font-weight: bold;
|
| 48 |
+
cursor: pointer;
|
| 49 |
+
font-size: 1rem;
|
| 50 |
+
}
|
| 51 |
+
button:disabled {
|
| 52 |
+
background: #ccc;
|
| 53 |
+
cursor: not-allowed;
|
| 54 |
+
}
|
| 55 |
+
.message {
|
| 56 |
+
text-align: center;
|
| 57 |
+
margin-top: 1rem;
|
| 58 |
+
color: #007aff;
|
| 59 |
+
}
|
| 60 |
+
.error {
|
| 61 |
+
color: #e74c3c;
|
| 62 |
+
}
|
| 63 |
+
</style>
|
| 64 |
+
</head>
|
| 65 |
+
<body>
|
| 66 |
+
<div class="card">
|
| 67 |
+
<h2>Reset your password</h2>
|
| 68 |
+
<input id="password" type="password" placeholder="Enter new password" />
|
| 69 |
+
<button id="resetBtn">Update Password</button>
|
| 70 |
+
<div id="message" class="message"></div>
|
| 71 |
+
</div>
|
| 72 |
+
|
| 73 |
+
<script>
|
| 74 |
+
const SUPABASE_URL = "https://sabzdinksnhtxkmuifhu.supabase.co"; // <-- replace
|
| 75 |
+
const SUPABASE_ANON_KEY = "sb_publishable_cnPXh7btnMgXgSh1uP2WHw_8254URhU"; // <-- replace
|
| 76 |
+
const supabase = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
| 77 |
+
|
| 78 |
+
const resetBtn = document.getElementById("resetBtn");
|
| 79 |
+
const messageDiv = document.getElementById("message");
|
| 80 |
+
|
| 81 |
+
async function init() {
|
| 82 |
+
const hashParams = window.location.hash.substring(1).split("&");
|
| 83 |
+
const params = {};
|
| 84 |
+
hashParams.forEach(p => {
|
| 85 |
+
const [key, value] = p.split("=");
|
| 86 |
+
params[key] = decodeURIComponent(value);
|
| 87 |
+
});
|
| 88 |
+
|
| 89 |
+
if (params.type === "recovery" && params.access_token) {
|
| 90 |
+
// automatically sign in using recovery token
|
| 91 |
+
const { data, error } = await supabase.auth.setSession({
|
| 92 |
+
access_token: params.access_token,
|
| 93 |
+
refresh_token: params.refresh_token
|
| 94 |
+
});
|
| 95 |
+
|
| 96 |
+
if (error) {
|
| 97 |
+
messageDiv.textContent = "Invalid or expired link.";
|
| 98 |
+
messageDiv.classList.add("error");
|
| 99 |
+
resetBtn.disabled = true;
|
| 100 |
+
}
|
| 101 |
+
} else {
|
| 102 |
+
messageDiv.textContent = "Invalid reset link.";
|
| 103 |
+
messageDiv.classList.add("error");
|
| 104 |
+
resetBtn.disabled = true;
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
resetBtn.addEventListener("click", async () => {
|
| 109 |
+
const password = document.getElementById("password").value.trim();
|
| 110 |
+
if (!password) return alert("Please enter a new password");
|
| 111 |
+
|
| 112 |
+
resetBtn.disabled = true;
|
| 113 |
+
messageDiv.textContent = "Updating password...";
|
| 114 |
+
|
| 115 |
+
const { data, error } = await supabase.auth.updateUser({ password });
|
| 116 |
+
|
| 117 |
+
if (error) {
|
| 118 |
+
messageDiv.textContent = error.message;
|
| 119 |
+
messageDiv.classList.add("error");
|
| 120 |
+
resetBtn.disabled = false;
|
| 121 |
+
} else {
|
| 122 |
+
messageDiv.textContent = "✅ Password successfully updated! You can close this page now.";
|
| 123 |
+
}
|
| 124 |
+
});
|
| 125 |
+
|
| 126 |
+
init();
|
| 127 |
+
</script>
|
| 128 |
+
</body>
|
| 129 |
+
</html>
|