Files
Link-Log/frontend/static/reset-password.js
T
Olaf 102d8e533c
Build LinkLog Development Image / development-image (push) Successful in 11s
Initial config with email service test
2026-08-25 23:23:28 +02:00

19 lines
919 B
JavaScript

// Copyright © 2026 Olaf Kolkman
// SPDX-License-Identifier: GPL-3.0-or-later
const resetForm = document.querySelector('#reset-password-form');
const resetStatus = document.querySelector('#reset-password-status');
const resetToken = new URLSearchParams(window.location.search).get('token');
resetForm.addEventListener('submit', async (event) => {
event.preventDefault();
const response = await fetch('/api/auth/reset-password', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({token: resetToken, password: new FormData(resetForm).get('password')}),
});
const result = await response.json();
resetStatus.textContent = response.ok ? `${result.message} Redirecting...` : (result.detail || 'Reset failed.');
resetStatus.style.color = response.ok ? '#166534' : '#b91c1c';
if (response.ok) window.setTimeout(() => window.location.assign('/login'), 1000);
});