From 1789fd76250ff00bc10d94b709fe666e96ed73e9 Mon Sep 17 00:00:00 2001 From: Zaine Arch Date: Sat, 9 May 2026 01:18:08 +0100 Subject: [PATCH] Revert "hehe 3" This reverts commit bebed1f788040cfb89007ac79a3415e25ef66d4d. --- assets/scripts/auth.js | 24 +++--------------------- posts/posts-list.org | 2 +- sitemap.org | 6 +++--- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/assets/scripts/auth.js b/assets/scripts/auth.js index 71d4de4..5d582a3 100644 --- a/assets/scripts/auth.js +++ b/assets/scripts/auth.js @@ -33,7 +33,6 @@ async function authFetch(input, options = {}) { const response = await fetch(input, { ...options, - credentials: options.credentials || "same-origin", headers: authHeaders(options.headers), }); @@ -48,7 +47,6 @@ async function login(username, password) { const response = await fetch("/api/auth/login", { method: "POST", - credentials: "same-origin", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password }), }); @@ -62,18 +60,6 @@ return data.token; } - async function hasServerSession() { - if (token()) return true; - - const response = await fetch("/api/auth/check", { - method: "GET", - credentials: "same-origin", - cache: "no-store", - }); - - return response.status === 204; - } - function initLoginForm() { const form = document.getElementById("login-form"); if (!form) return; @@ -105,19 +91,15 @@ fetch: authFetch, headers: authHeaders, token, - logout: async () => { - await fetch("/api/auth/logout", { - method: "POST", - credentials: "same-origin", - }).catch(() => {}); + logout: () => { window.localStorage.removeItem(TOKEN_KEY); redirectToLogin(); }, }; - document.addEventListener("DOMContentLoaded", async () => { + document.addEventListener("DOMContentLoaded", () => { initLoginForm(); - if (!isLoginPage() && !(await hasServerSession())) { + if (!isLoginPage() && !token()) { redirectToLogin(); } }); diff --git a/posts/posts-list.org b/posts/posts-list.org index 90d111b..c0ec23e 100644 --- a/posts/posts-list.org +++ b/posts/posts-list.org @@ -4,7 +4,7 @@ See the categories: @@html:Categories@@ * Posts: -- [[file:career/career-list.org][Career List]] @@html:09-05-2026 01:10@@ +- [[file:career/career-list.org][Career List]] @@html:09-05-2026 00:54@@ - [[file:posts-list.sync-conflict-20260509-005434-VT6366A.org][Posts List]] @@html:09-05-2026 00:54@@ - [[file:posts-list.sync-conflict-20260417-233432-VT6366A.org][Posts List]] @@html:14-04-2026 16:36@@ - [[file:career/ha-dr.org][High Availability, Disaster Recovery and Business Continuity]] @@html:11-03-2026 17:18@@ @@html:@@ @@html:@@ diff --git a/sitemap.org b/sitemap.org index 66bd71d..767257a 100644 --- a/sitemap.org +++ b/sitemap.org @@ -13,12 +13,12 @@ - [[file:tags/notes.org][Tag: notes]] - [[file:tags/review.org][Tag: review]] - [[file:tags/website.org][Tag: website]] - - [[file:tags/update.org][Tag: update]] - [[file:tags/life.org][Tag: life]] - - [[file:tags/education.org][Tag: education]] + - [[file:tags/update.org][Tag: update]] - [[file:tags/insights.org][Tag: insights]] - - [[file:tags/reading.org][Tag: reading]] - [[file:tags/emacs.org][Tag: emacs]] + - [[file:tags/education.org][Tag: education]] + - [[file:tags/reading.org][Tag: reading]] - [[file:tags/maths.org][Tag: maths]] - books - [[file:books/books-list.org][Books List]]