Update reset.html
Browse files- reset.html +13 -3
reset.html
CHANGED
|
@@ -71,10 +71,18 @@
|
|
| 71 |
</div>
|
| 72 |
|
| 73 |
<script>
|
| 74 |
-
|
| 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 |
|
|
@@ -86,9 +94,11 @@
|
|
| 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
|
| 92 |
access_token: params.access_token,
|
| 93 |
refresh_token: params.refresh_token
|
| 94 |
});
|
|
@@ -112,7 +122,7 @@
|
|
| 112 |
resetBtn.disabled = true;
|
| 113 |
messageDiv.textContent = "Updating password...";
|
| 114 |
|
| 115 |
-
const { data, error } = await
|
| 116 |
|
| 117 |
if (error) {
|
| 118 |
messageDiv.textContent = error.message;
|
|
|
|
| 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 |
|
| 79 |
+
const SUPABASE_URL = "https://sabzdinksnhtxkmuifhu.supabase.co";
|
| 80 |
+
const SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNhYnpkaW5rc25odHhrbXVpZmh1Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzE0NDYwMTIsImV4cCI6MjA0NzAyMjAxMn0.f0g8rrFDCELdKm4h0iEgX-0CXUY4dUHYOBk1wxf-c7I";
|
| 81 |
+
|
| 82 |
+
// Use window.supabase (the global from CDN) instead of const supabase
|
| 83 |
+
const { createClient } = window.supabase;
|
| 84 |
+
const supabaseClient = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
| 85 |
+
|
| 86 |
const resetBtn = document.getElementById("resetBtn");
|
| 87 |
const messageDiv = document.getElementById("message");
|
| 88 |
|
|
|
|
| 94 |
params[key] = decodeURIComponent(value);
|
| 95 |
});
|
| 96 |
|
| 97 |
+
alert(params.type === "recovery" && params.access_token);
|
| 98 |
+
|
| 99 |
if (params.type === "recovery" && params.access_token) {
|
| 100 |
// automatically sign in using recovery token
|
| 101 |
+
const { data, error } = await supabaseClient.auth.setSession({
|
| 102 |
access_token: params.access_token,
|
| 103 |
refresh_token: params.refresh_token
|
| 104 |
});
|
|
|
|
| 122 |
resetBtn.disabled = true;
|
| 123 |
messageDiv.textContent = "Updating password...";
|
| 124 |
|
| 125 |
+
const { data, error } = await supabaseClient.auth.updateUser({ password });
|
| 126 |
|
| 127 |
if (error) {
|
| 128 |
messageDiv.textContent = error.message;
|