From e2496cf17d2cf0a49f46a149edfc57bf9e1b39ba Mon Sep 17 00:00:00 2001 From: echarp Date: Mon, 14 Nov 2022 18:10:59 +0100 Subject: [PATCH] Check if user is authenticated --- themes/acoeur/assets/js/setup.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/acoeur/assets/js/setup.js b/themes/acoeur/assets/js/setup.js index be59488..70fc520 100644 --- a/themes/acoeur/assets/js/setup.js +++ b/themes/acoeur/assets/js/setup.js @@ -12,10 +12,10 @@ if (topSection) document.body.classList.add(topSection) if ('pages' === topSection) { document.body.classList.add('author') } else { - // Check if access is authorized to root page - // xBasic is to not have the authentication popup - fetch('/', {headers: {'WWW-Authenticate': 'xBasic'}}) - .then(result => { if (result.status === 200) document.body.classList.add('author') }) + // Special URL which does not require authentication but returns browser's headers + // thus we can deduce if user is authenticated + fetch('/author') + .then(result => { if (result.headers.get('authorization')) document.body.classList.add('author') }) } // Setup a "property" attribute, to send to the backend for insertion/update/deletion