From 4b41eddf44244e0475eec8681e7d1f2f399dd181 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 30 Mar 2019 19:24:53 +0100 Subject: [PATCH] fix creating note directly as protected --- src/services/notes.js | 3 ++- src/services/protected_session.js | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/services/notes.js b/src/services/notes.js index 7509956bf..7598cde80 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -95,7 +95,8 @@ async function createNewNote(parentNoteId, noteData) { note.noteContent = await new NoteContent({ noteId: note.noteId, - content: noteData.content + content: noteData.content, + isProtected: noteData.isProtected }).save(); const branch = await new Branch({ diff --git a/src/services/protected_session.js b/src/services/protected_session.js index cf90871ae..d2ad3250a 100644 --- a/src/services/protected_session.js +++ b/src/services/protected_session.js @@ -86,12 +86,17 @@ function decryptNoteRevision(hist) { return; } - if (hist.title) { - hist.title = dataEncryptionService.decryptString(dataKey, hist.title); - } + try { + if (hist.title) { + hist.title = dataEncryptionService.decryptString(dataKey, hist.title); + } - if (hist.content) { - hist.content = dataEncryptionService.decryptString(dataKey, hist.content); + if (hist.content) { + hist.content = dataEncryptionService.decryptString(dataKey, hist.content); + } + } + catch (e) { + throw new Error(`Decryption failed for note ${hist.noteId}: ` + e.message + " " + e.stack); } }