A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: ask password before restoring encrypted backup
thecodrr2fb5550c2085
diff --git a/apps/web/src/common/dialogcontroller.js b/apps/web/src/common/dialogcontroller.jsindex a768b22da..ba10a79ca 100644--- a/apps/web/src/common/dialogcontroller.js+++ b/apps/web/src/common/dialogcontroller.js@@ -354,6 +354,13 @@ function getDialogData(type) {subtitle: "Please enter your vault password to continue.",positiveButtonText: "Unlock",};+ case "ask_backup_password":+ return {+ title: "Encrypted backup",+ subtitle:+ "Please enter the password to decrypt and restore this backup.",+ positiveButtonText: "Restore",+ };case "change_account_password":return {title: "Change account password",diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.jsindex 23487fdb2..b5f437112 100644--- a/apps/web/src/components/editor/tinymce.js+++ b/apps/web/src/components/editor/tinymce.js@@ -203,10 +203,11 @@ function TinyMCE(props) {id={sessionId}ref={tinymceRef}onFocus={onFocus}- onDrop={(e,editor) => {+ onDrop={(e, editor) => {for (let file of e.dataTransfer.files) {- attachFile(editor, file)- }}}+ attachFile(editor, file);+ }+ }}init={{//experimentalkeep_styles: false,diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.jsindex 1c5f9f4c4..a323f37e6 100644--- a/apps/web/src/views/settings.js+++ b/apps/web/src/views/settings.js@@ -369,7 +369,7 @@ function Settings(props) {type="file"id="restore-backup"hidden- accept=".nnbackup,text/plain,application/json"+ accept=".nnbackup,application/json"/><Buttonvariant="list"@@ -380,18 +380,29 @@ function Settings(props) {"You must be logged in to restore backups.");- const backupData = JSON.stringify(await importBackup());- const error = await showLoadingDialog({- title: "Restoring backup",- subtitle:- "Please do NOT close your browser or shut down your PC.",- action: () => db.backup.import(backupData),- });- if (!error) {- await showToast("success", "Backup restored!");+ const backup = await importBackup();++ async function restore(password) {+ await db.backup.import(backup, password);await refreshApp();+ showToast("success", "Backup restored!");+ }++ if (backup.data.iv && backup.data.salt) {+ await showPasswordDialog(+ "ask_backup_password",+ async ({ password }) => {+ const error = await restore(password);+ return !error;+ }+ );} else {- throw new Error(error);+ await showLoadingDialog({+ title: "Restoring backup",+ subtitle:+ "Please do NOT close your browser or shut down your PC until the process completes.",+ action: restore,+ });}} catch (e) {console.error(e);