mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	protect tree will check if password is set and send user to options if not
This commit is contained in:
		| @@ -5,7 +5,7 @@ import utils from "../services/utils.js"; | |||||||
|  |  | ||||||
| const $dialog = $("#options-dialog"); | const $dialog = $("#options-dialog"); | ||||||
|  |  | ||||||
| export async function showDialog() { | export async function showDialog(openTab) { | ||||||
|     const options = await server.get('options'); |     const options = await server.get('options'); | ||||||
|  |  | ||||||
|     utils.openDialog($dialog); |     utils.openDialog($dialog); | ||||||
| @@ -14,7 +14,7 @@ export async function showDialog() { | |||||||
|         import('./options/appearance.js'), |         import('./options/appearance.js'), | ||||||
|         import('./options/shortcuts.js'), |         import('./options/shortcuts.js'), | ||||||
|         import('./options/code_notes.js'), |         import('./options/code_notes.js'), | ||||||
|         import('./options/credentials.js'), |         import('./options/password.js'), | ||||||
|         import('./options/backup.js'), |         import('./options/backup.js'), | ||||||
|         import('./options/sync.js'), |         import('./options/sync.js'), | ||||||
|         import('./options/other.js'), |         import('./options/other.js'), | ||||||
| @@ -26,4 +26,8 @@ export async function showDialog() { | |||||||
|                 tab.optionsLoaded(options) |                 tab.optionsLoaded(options) | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |     if (openTab) { | ||||||
|  |         $(`.nav-link[href='#options-${openTab}']`).trigger("click"); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ const TPL = ` | |||||||
| 
 | 
 | ||||||
| export default class ChangePasswordOptions { | export default class ChangePasswordOptions { | ||||||
|     constructor() { |     constructor() { | ||||||
|         $("#options-credentials").html(TPL); |         $("#options-password").html(TPL); | ||||||
| 
 | 
 | ||||||
|         this.$passwordHeading = $("#password-heading"); |         this.$passwordHeading = $("#password-heading"); | ||||||
|         this.$form = $("#change-password-form"); |         this.$form = $("#change-password-form"); | ||||||
							
								
								
									
										13
									
								
								src/public/app/dialogs/password_not_set.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/public/app/dialogs/password_not_set.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | import utils from "../services/utils.js"; | ||||||
|  | import appContext from "../services/app_context.js"; | ||||||
|  |  | ||||||
|  | export function show() { | ||||||
|  |     const $dialog = $("#password-not-set-dialog"); | ||||||
|  |     const $openPasswordOptionsButton = $("#open-password-options-button"); | ||||||
|  |  | ||||||
|  |     utils.openDialog($dialog); | ||||||
|  |  | ||||||
|  |     $openPasswordOptionsButton.on("click", () => { | ||||||
|  |         appContext.triggerCommand("showOptions", { openTab: 'password' }); | ||||||
|  |     }); | ||||||
|  | } | ||||||
| @@ -12,7 +12,7 @@ export function show() { | |||||||
| } | } | ||||||
|  |  | ||||||
| export function close() { | export function close() { | ||||||
|     // this may fal if the dialog has not been previously opened (not sure if still true with Bootstrap modal) |     // this may fail if the dialog has not been previously opened (not sure if still true with Bootstrap modal) | ||||||
|     try { |     try { | ||||||
|         $dialog.modal('hide'); |         $dialog.modal('hide'); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ import ws from "./ws.js"; | |||||||
| import appContext from "./app_context.js"; | import appContext from "./app_context.js"; | ||||||
| import froca from "./froca.js"; | import froca from "./froca.js"; | ||||||
| import utils from "./utils.js"; | import utils from "./utils.js"; | ||||||
|  | import options from "./options.js"; | ||||||
|  |  | ||||||
| let protectedSessionDeferred = null; | let protectedSessionDeferred = null; | ||||||
|  |  | ||||||
| @@ -18,6 +19,11 @@ async function leaveProtectedSession() { | |||||||
| function enterProtectedSession() { | function enterProtectedSession() { | ||||||
|     const dfd = $.Deferred(); |     const dfd = $.Deferred(); | ||||||
|  |  | ||||||
|  |     if (!options.is("isPasswordSet")) { | ||||||
|  |         import("../dialogs/password_not_set.js").then(dialog => dialog.show()); | ||||||
|  |         return dfd; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     if (protectedSessionHolder.isProtectedSessionAvailable()) { |     if (protectedSessionHolder.isProtectedSessionAvailable()) { | ||||||
|         dfd.resolve(false); |         dfd.resolve(false); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -53,8 +53,8 @@ export default class RootCommandExecutor extends Component { | |||||||
|         d.showDialog(branchIds); |         d.showDialog(branchIds); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     showOptionsCommand() { |     showOptionsCommand({openTab}) { | ||||||
|         import("../dialogs/options.js").then(d => d.showDialog()); |         import("../dialogs/options.js").then(d => d.showDialog(openTab)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     showHelpCommand() { |     showHelpCommand() { | ||||||
|   | |||||||
| @@ -39,6 +39,7 @@ | |||||||
| <%- include('dialogs/include_note.ejs') %> | <%- include('dialogs/include_note.ejs') %> | ||||||
| <%- include('dialogs/sort_child_notes.ejs') %> | <%- include('dialogs/sort_child_notes.ejs') %> | ||||||
| <%- include('dialogs/delete_notes.ejs') %> | <%- include('dialogs/delete_notes.ejs') %> | ||||||
|  | <%- include('dialogs/password_not_set.ejs') %> | ||||||
|  |  | ||||||
| <script type="text/javascript"> | <script type="text/javascript"> | ||||||
|     global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */ |     global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */ | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ | |||||||
|                             <a class="nav-link" data-toggle="tab" href="#options-code-notes">Code notes</a> |                             <a class="nav-link" data-toggle="tab" href="#options-code-notes">Code notes</a> | ||||||
|                         </li> |                         </li> | ||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|                             <a class="nav-link" data-toggle="tab" href="#options-credentials">Password</a> |                             <a class="nav-link" data-toggle="tab" href="#options-password">Password</a> | ||||||
|                         </li> |                         </li> | ||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|                             <a class="nav-link" data-toggle="tab" href="#options-backup">Backup</a> |                             <a class="nav-link" data-toggle="tab" href="#options-backup">Backup</a> | ||||||
| @@ -40,7 +40,7 @@ | |||||||
|                         <div id="options-appearance" class="tab-pane active"></div> |                         <div id="options-appearance" class="tab-pane active"></div> | ||||||
|                         <div id="options-shortcuts" class="tab-pane"></div> |                         <div id="options-shortcuts" class="tab-pane"></div> | ||||||
|                         <div id="options-code-notes" class="tab-pane"></div> |                         <div id="options-code-notes" class="tab-pane"></div> | ||||||
|                         <div id="options-credentials" class="tab-pane"></div> |                         <div id="options-password" class="tab-pane"></div> | ||||||
|                         <div id="options-backup" class="tab-pane"></div> |                         <div id="options-backup" class="tab-pane"></div> | ||||||
|                         <div id="options-sync-setup" class="tab-pane"></div> |                         <div id="options-sync-setup" class="tab-pane"></div> | ||||||
|                         <div id="options-other" class="tab-pane"></div> |                         <div id="options-other" class="tab-pane"></div> | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								src/views/dialogs/password_not_set.ejs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/views/dialogs/password_not_set.ejs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | <div id="password-not-set-dialog" class="modal fade mx-auto" tabindex="-1" role="dialog"> | ||||||
|  |     <div class="modal-dialog modal-md" role="document"> | ||||||
|  |         <div class="modal-content"> | ||||||
|  |             <div class="modal-header"> | ||||||
|  |                 <h5 class="modal-title mr-auto">Password is not set</h5> | ||||||
|  |  | ||||||
|  |                 <button type="button" class="close" data-dismiss="modal" aria-label="Close" style="margin-left: 0;"> | ||||||
|  |                     <span aria-hidden="true">×</span> | ||||||
|  |                 </button> | ||||||
|  |             </div> | ||||||
|  |             <div class="modal-body"> | ||||||
|  |                 Protected notes are encrypted using a user password, but password has not been set yet. | ||||||
|  |  | ||||||
|  |                 To be able to protect notes, <a id="open-password-options-button" href="javascript:"> | ||||||
|  |                     click here to open the Options dialog</a> and set your password. | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |     </div> | ||||||
|  | </div> | ||||||
		Reference in New Issue
	
	Block a user