Check if user is authenticated

This commit is contained in:
echarp 2022-11-14 18:10:59 +01:00
parent 62640cf60d
commit e2496cf17d
1 changed files with 4 additions and 4 deletions

View File

@ -12,10 +12,10 @@ if (topSection) document.body.classList.add(topSection)
if ('pages' === topSection) { if ('pages' === topSection) {
document.body.classList.add('author') document.body.classList.add('author')
} else { } else {
// Check if access is authorized to root page // Special URL which does not require authentication but returns browser's headers
// xBasic is to not have the authentication popup // thus we can deduce if user is authenticated
fetch('/', {headers: {'WWW-Authenticate': 'xBasic'}}) fetch('/author')
.then(result => { if (result.status === 200) document.body.classList.add('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 // Setup a "property" attribute, to send to the backend for insertion/update/deletion