Skip to content

Commit

Permalink
Merge pull request #1 from Karta-Creative/merlinbergmann-patch-1
Browse files Browse the repository at this point in the history
Update reset-password.html
  • Loading branch information
merlinbergmann authored Jan 14, 2025
2 parents a58445c + c89ede5 commit 4934ca0
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions reset-password.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,27 @@ <h1>Reset Your Password</h1>
</div>

<script>
// Your existing JavaScript code...

// Update status message styling
// 1) Initialize
const SUPABASE_URL = 'https://xbkphiqrblzbgxpynndc.supabase.co';
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inhia3BoaXFyYmx6Ymd4cHlubmRjIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzYyNDU1NjYsImV4cCI6MjA1MTgyMTU2Nn0.NRhA1nb3kTzfJyi-9zw5-acni6R6fxJthVTJbBecogk';
const supabase = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);

const statusEl = document.getElementById('status');
const resetBtn = document.getElementById('resetBtn');
const resetForm = document.getElementById('resetForm');

// parse tokens from URL
const hashParams = new URLSearchParams(window.location.hash.substring(1));
const accessToken = hashParams.get('access_token');
const refreshToken = hashParams.get('refresh_token');

// 2) Update status function
function updateStatus(message, isError = false) {
statusEl.innerText = message;
statusEl.className = 'message ' + (isError ? 'error' : 'success');
}

// Replace status updates with the new function
// 3) Set session if needed
async function setSessionIfNeeded() {
if (accessToken && refreshToken) {
const { data, error } = await supabase.auth.setSession({
Expand All @@ -155,6 +167,7 @@ <h1>Reset Your Password</h1>
}
}

// 4) Handle form submission
resetForm.addEventListener('submit', async (e) => {
e.preventDefault();
console.log('Form submitted!');
Expand All @@ -172,13 +185,16 @@ <h1>Reset Your Password</h1>
if (error) {
updateStatus('Error updating password: ' + error.message, true);
} else {
updateStatus('Password updated successfully! You can now close this tab or log in again.');
updateStatus('Password updated successfully! You can now close this tab and log in with your new password on the D2 app.');
resetBtn.disabled = true;
}
} catch (err) {
updateStatus('Exception: ' + err.message, true);
}
});

// 5) Fire on page load
document.addEventListener('DOMContentLoaded', setSessionIfNeeded);
</script>
</body>
</html>

0 comments on commit 4934ca0

Please sign in to comment.