diff --git a/src/routes/journals/+layout.svelte b/src/routes/journals/+layout.svelte index 914f7118..57af086c 100644 --- a/src/routes/journals/+layout.svelte +++ b/src/routes/journals/+layout.svelte @@ -71,6 +71,7 @@ if (browser) { +{#if $ae_loc.user_id && $ae_loc.person_id && $ae_loc.trusted_access}
@@ -192,3 +193,11 @@ if (browser) {
+ +{:else} +
+

+ You are not logged in as a user. You must be signed in to access the journals module. +

+
+{/if} diff --git a/src/routes/journals/[journal_id]/+page.svelte b/src/routes/journals/[journal_id]/+page.svelte index 1b0626b3..22ee4157 100644 --- a/src/routes/journals/[journal_id]/+page.svelte +++ b/src/routes/journals/[journal_id]/+page.svelte @@ -155,6 +155,7 @@ if (browser) { +{#if $ae_loc.person_id == $lq__journal_obj?.person_id} +{#if $ae_loc.person_id == $lq__journal_obj?.person_id}
+
+

+ You must be logged in as the owner to view this Journal Entry. +

+
- {#snippet header()} - -
-

- {#if $ae_loc.trusted_access} - - - - {/if} - - - Edit Journal Entry: - - {$lq__journal_entry_obj?.name} -

-
- - - {/snippet} - - - - - - - - - - - - - - - +{/if} \ No newline at end of file diff --git a/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte b/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte index a4a9b4fe..dab2f11b 100644 --- a/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte +++ b/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte @@ -10,7 +10,7 @@ import { Eye, EyeOff, Flag, FlagOff, FileX, Fingerprint, Globe, Group, - LockKeyholeOpen, + LockKeyhole, LockKeyholeOpen, MessageSquareWarning, Minus, NotebookPen, NotebookText, NotepadTextDashed, Pencil, PenLine, Plus, @@ -192,9 +192,11 @@ async function update_journal_entry() { data_kv.content = content; decrypted_content = ''; } else if (tmp_entry_obj?.content_encrypted && !tmp_entry_obj?.private) { - // alert('You must decrypt the content before saving it.'); - console.log('TEST: You must decrypt the content before saving it.'); - return false; + console.log('TEST: Decrypting the content before saving it...'); + await handle_decrypt_content(); + data_kv.content = decrypted_content; // tmp_entry_obj.content + decrypted_content = ''; + // return false; } else { console.log('TEST: Saving content without encryption', tmp_entry_obj?.content); // Clear content_encrypted again. Just in case. @@ -307,39 +309,10 @@ $effect(() => { $effect(async () => { if (tmp_entry_obj?.content_encrypted && trigger_decrypt) { trigger_decrypt = false; - log_lvl = 1; - let combined_data = tmp_entry_obj?.content_encrypted; - let [encryption_iv_hex, encrypted_base64_content] = combined_data.split(':'); - encryption_iv = new Uint8Array(encryption_iv_hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - if (log_lvl) { - console.log(`IV: ${encryption_iv}; Encrypted: ${encrypted_base64_content}`); - } + handle_decrypt_content(); - let decrypted: string|null = null; - try { - decrypted = await ae_util.decrypt_content(encrypted_base64_content, encryption_iv, journal_key); - } catch (error) { - console.error('Error decrypting content:', error); - alert('Failed to decrypt content. Please check the passcode.'); - return; - } - // let decrypted = await ae_util.decrypt_content(encrypted_base64_content, encryption_iv, journal_key); - // decrypted_content = 'XXX '+decrypted+' XXX'; - if (!decrypted) { - alert('Failed to decrypt content. Please check the passcode.'); - return; - } - decrypted_content = decrypted; - if (log_lvl) { - console.log('Decrypted content:', decrypted_content); - } - tmp_entry_obj.content = decrypted_content; - // orig_entry_obj.content = decrypted_content; - // tmp_entry_obj_changed = false; - - // tmp_entry_obj.content_encrypted = null; } // if (tmp_entry_obj?.content) { @@ -359,6 +332,44 @@ $effect(async () => { // console.log('IV:', iv); }); +async function handle_decrypt_content() { + log_lvl = 1; + if (log_lvl) { + console.log('TEST: handle_decrypt_content'); + } + let combined_data = tmp_entry_obj?.content_encrypted; + let [encryption_iv_hex, encrypted_base64_content] = combined_data.split(':'); + encryption_iv = new Uint8Array(encryption_iv_hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); + if (log_lvl) { + console.log(`IV: ${encryption_iv}; Encrypted: ${encrypted_base64_content}`); + } + + let decrypted: string|null = null; + try { + decrypted = await ae_util.decrypt_content(encrypted_base64_content, encryption_iv, journal_key); + } catch (error) { + console.error('Error decrypting content:', error); + alert('Failed to decrypt content. Please check the passcode.'); + return; + } + // let decrypted = await ae_util.decrypt_content(encrypted_base64_content, encryption_iv, journal_key); + // decrypted_content = 'XXX '+decrypted+' XXX'; + + if (!decrypted) { + alert('Failed to decrypt content. Please check the passcode.'); + return; + } + decrypted_content = decrypted; + if (log_lvl) { + console.log('Decrypted content:', decrypted_content); + } + tmp_entry_obj.content = decrypted_content; + // orig_entry_obj.content = decrypted_content; + // tmp_entry_obj_changed = false; + + // tmp_entry_obj.content_encrypted = null; +} + @@ -697,63 +708,85 @@ $effect(async () => { {/if} - + + + + + +
\ No newline at end of file +