Working signout button

This commit is contained in:
Olaf
2026-08-24 19:56:28 +02:00
parent 28a01175f7
commit 12f3580f60
17 changed files with 252 additions and 10 deletions
+14
View File
@@ -1,5 +1,6 @@
(() => {
const profileForm = document.querySelector('#profile-form');
const passwordForm = document.querySelector('#password-form');
const mastodonForm = document.querySelector('#mastodon-form');
const profileLogoutButton = document.querySelector('#logout-button');
const accessToken = localStorage.getItem('linklogAccessToken');
@@ -90,6 +91,19 @@ mastodonForm.addEventListener('submit', async (event) => {
setStatus('#mastodon-status', response.ok ? 'Mastodon settings saved.' : 'Could not save Mastodon settings.', !response.ok);
});
passwordForm.addEventListener('submit', async (event) => {
event.preventDefault();
const response = await fetch('/api/user/password', {
method: 'PUT',
headers: authHeaders(true),
body: JSON.stringify(Object.fromEntries(new FormData(passwordForm))),
});
const status = document.querySelector('#password-status');
status.textContent = response.ok ? 'Password changed.' : 'Could not change password.';
status.style.color = response.ok ? '#94e2d5' : '#f38ba8';
if (response.ok) passwordForm.reset();
});
Promise.all([loadProfile(), loadMastodonConfig()]).catch((error) => {
setStatus('#profile-status', accessToken ? error.message : 'Please sign in first.', true);
});