Revert "hehe 3"

This reverts commit bebed1f788.
This commit is contained in:
2026-05-09 01:18:08 +01:00
parent bebed1f788
commit 1789fd7625
3 changed files with 7 additions and 25 deletions

View File

@@ -33,7 +33,6 @@
async function authFetch(input, options = {}) { async function authFetch(input, options = {}) {
const response = await fetch(input, { const response = await fetch(input, {
...options, ...options,
credentials: options.credentials || "same-origin",
headers: authHeaders(options.headers), headers: authHeaders(options.headers),
}); });
@@ -48,7 +47,6 @@
async function login(username, password) { async function login(username, password) {
const response = await fetch("/api/auth/login", { const response = await fetch("/api/auth/login", {
method: "POST", method: "POST",
credentials: "same-origin",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username, password }), body: JSON.stringify({ username, password }),
}); });
@@ -62,18 +60,6 @@
return data.token; 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() { function initLoginForm() {
const form = document.getElementById("login-form"); const form = document.getElementById("login-form");
if (!form) return; if (!form) return;
@@ -105,19 +91,15 @@
fetch: authFetch, fetch: authFetch,
headers: authHeaders, headers: authHeaders,
token, token,
logout: async () => { logout: () => {
await fetch("/api/auth/logout", {
method: "POST",
credentials: "same-origin",
}).catch(() => {});
window.localStorage.removeItem(TOKEN_KEY); window.localStorage.removeItem(TOKEN_KEY);
redirectToLogin(); redirectToLogin();
}, },
}; };
document.addEventListener("DOMContentLoaded", async () => { document.addEventListener("DOMContentLoaded", () => {
initLoginForm(); initLoginForm();
if (!isLoginPage() && !(await hasServerSession())) { if (!isLoginPage() && !token()) {
redirectToLogin(); redirectToLogin();
} }
}); });

View File

@@ -4,7 +4,7 @@
See the categories: @@html:<a href="../home/categories.html">Categories</a>@@ See the categories: @@html:<a href="../home/categories.html">Categories</a>@@
* Posts: * Posts:
- [[file:career/career-list.org][Career List]] @@html:<span class="post-date">09-05-2026 01:10</span>@@ - [[file:career/career-list.org][Career List]] @@html:<span class="post-date">09-05-2026 00:54</span>@@
- [[file:posts-list.sync-conflict-20260509-005434-VT6366A.org][Posts List]] @@html:<span class="post-date">09-05-2026 00:54</span>@@ - [[file:posts-list.sync-conflict-20260509-005434-VT6366A.org][Posts List]] @@html:<span class="post-date">09-05-2026 00:54</span>@@
- [[file:posts-list.sync-conflict-20260417-233432-VT6366A.org][Posts List]] @@html:<span class="post-date">14-04-2026 16:36</span>@@ - [[file:posts-list.sync-conflict-20260417-233432-VT6366A.org][Posts List]] @@html:<span class="post-date">14-04-2026 16:36</span>@@
- [[file:career/ha-dr.org][High Availability, Disaster Recovery and Business Continuity]] @@html:<span class="post-date">11-03-2026 17:18</span>@@ @@html:<a href="/tags/learning.html"><span class="post-tag">learning</span></a>@@ @@html:<a href="/tags/notes.html"><span class="post-tag">notes</span></a>@@ - [[file:career/ha-dr.org][High Availability, Disaster Recovery and Business Continuity]] @@html:<span class="post-date">11-03-2026 17:18</span>@@ @@html:<a href="/tags/learning.html"><span class="post-tag">learning</span></a>@@ @@html:<a href="/tags/notes.html"><span class="post-tag">notes</span></a>@@

View File

@@ -13,12 +13,12 @@
- [[file:tags/notes.org][Tag: notes]] - [[file:tags/notes.org][Tag: notes]]
- [[file:tags/review.org][Tag: review]] - [[file:tags/review.org][Tag: review]]
- [[file:tags/website.org][Tag: website]] - [[file:tags/website.org][Tag: website]]
- [[file:tags/update.org][Tag: update]]
- [[file:tags/life.org][Tag: life]] - [[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/insights.org][Tag: insights]]
- [[file:tags/reading.org][Tag: reading]]
- [[file:tags/emacs.org][Tag: emacs]] - [[file:tags/emacs.org][Tag: emacs]]
- [[file:tags/education.org][Tag: education]]
- [[file:tags/reading.org][Tag: reading]]
- [[file:tags/maths.org][Tag: maths]] - [[file:tags/maths.org][Tag: maths]]
- books - books
- [[file:books/books-list.org][Books List]] - [[file:books/books-list.org][Books List]]