fix password protected notes rejection

This commit is contained in:
zadam 2022-08-01 19:56:09 +02:00
parent 46deceedc9
commit e5fdd5128a
2 changed files with 5 additions and 2 deletions

1
package-lock.json generated
View file

@ -5,6 +5,7 @@
"requires": true,
"packages": {
"": {
"name": "trilium",
"version": "0.53.2",
"hasInstallScript": true,
"license": "AGPL-3.0-only",

View file

@ -30,7 +30,7 @@ function addNoIndexHeader(note, res) {
}
}
function reject(res) {
function requestCredentials(res) {
res.setHeader('WWW-Authenticate', 'Basic realm="User Visible Realm", charset="UTF-8"')
.sendStatus(401);
}
@ -55,7 +55,7 @@ function checkNoteAccess(noteId, req, res) {
const header = req.header("Authorization");
if (!header?.startsWith("Basic ")) {
reject(res);
requestCredentials(res);
return false;
}
@ -80,6 +80,8 @@ function register(router) {
}
if (!checkNoteAccess(note.noteId, req, res)) {
requestCredentials(res);
return;
}