Fix CSRF token and currentUser references in api.js
Build and Push Docker Image / build (push) Successful in 52s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m17s
CI / Security audit (push) Successful in 1m31s
CI / Tests & coverage (push) Successful in 1m47s

- Use state.csrfToken instead of undefined csrfToken in handleLogout
- Use state.currentUser instead of undefined currentUser in handleLogout
- Use state.csrfToken instead of undefined csrfToken in enableSonarrWebhook
- Fixes ReferenceError bugs in logout and webhook functions
This commit is contained in:
2026-05-21 02:17:48 +01:00
parent 05cf5a0993
commit 9a4408e797
+4 -4
View File
@@ -57,10 +57,10 @@ export async function handleLogout() {
try {
await fetch('/api/auth/logout', {
method: 'POST',
headers: csrfToken ? { 'X-CSRF-Token': csrfToken } : {}
headers: state.csrfToken ? { 'X-CSRF-Token': state.csrfToken } : {}
});
currentUser = null;
csrfToken = null;
state.currentUser = null;
state.csrfToken = null;
return { success: true };
} catch (err) {
console.error('Logout failed:', err);
@@ -203,7 +203,7 @@ export async function enableSonarrWebhook() {
try {
const res = await fetch('/api/sonarr/notifications/sofarr-webhook', {
method: 'POST',
headers: { 'X-CSRF-Token': csrfToken || '' }
headers: { 'X-CSRF-Token': state.csrfToken || '' }
});
if (!res.ok) throw new Error('Failed to enable');
await fetchWebhookStatus();