mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-27 01:51:34 +08:00 
			
		
		
		
	removed username/password from setup
This commit is contained in:
		
							parent
							
								
									a910034c96
								
							
						
					
					
						commit
						7e48d214ca
					
				| @ -19,11 +19,6 @@ function SetupModel() { | ||||
|     this.setupSyncFromDesktop = ko.observable(false); | ||||
|     this.setupSyncFromServer = ko.observable(false); | ||||
| 
 | ||||
|     this.username = ko.observable(); | ||||
|     this.password1 = ko.observable(); | ||||
|     this.password2 = ko.observable(); | ||||
| 
 | ||||
|     this.theme = ko.observable("light"); | ||||
|     this.syncServerHost = ko.observable(); | ||||
|     this.syncProxy = ko.observable(); | ||||
| 
 | ||||
| @ -32,7 +27,16 @@ function SetupModel() { | ||||
|     this.setupTypeSelected = () => !!this.setupType(); | ||||
| 
 | ||||
|     this.selectSetupType = () => { | ||||
|         this.step(this.setupType()); | ||||
|         if (this.setupType() === 'new-document') { | ||||
|             this.step('new-document-in-progress'); | ||||
| 
 | ||||
|             $.post('api/setup/new-document').then(() => { | ||||
|                 window.location.replace("./setup"); | ||||
|             }); | ||||
|         } | ||||
|         else { | ||||
|             this.step(this.setupType()); | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     this.back = () => { | ||||
| @ -42,77 +46,43 @@ function SetupModel() { | ||||
|     }; | ||||
| 
 | ||||
|     this.finish = async () => { | ||||
|         if (this.setupType() === 'new-document') { | ||||
|             const username = this.username(); | ||||
|             const password1 = this.password1(); | ||||
|             const password2 = this.password2(); | ||||
|             const theme = this.theme(); | ||||
|         const syncServerHost = this.syncServerHost(); | ||||
|         const syncProxy = this.syncProxy(); | ||||
|         const username = this.username(); | ||||
|         const password = this.password1(); | ||||
| 
 | ||||
|             if (!username) { | ||||
|                 showAlert("Username can't be empty"); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             if (!password1) { | ||||
|                 showAlert("Password can't be empty"); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             if (password1 !== password2) { | ||||
|                 showAlert("Both password fields need be identical."); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             this.step('new-document-in-progress'); | ||||
| 
 | ||||
|             // not using server.js because it loads too many dependencies
 | ||||
|             $.post('api/setup/new-document', { | ||||
|                 username: username, | ||||
|                 password: password1, | ||||
|                 theme: theme | ||||
|             }).then(() => { | ||||
|                 window.location.replace("./setup"); | ||||
|             }); | ||||
|         if (!syncServerHost) { | ||||
|             showAlert("Trilium server address can't be empty"); | ||||
|             return; | ||||
|         } | ||||
|         else if (this.setupType() === 'sync-from-server') { | ||||
|             const syncServerHost = this.syncServerHost(); | ||||
|             const syncProxy = this.syncProxy(); | ||||
|             const username = this.username(); | ||||
|             const password = this.password1(); | ||||
| 
 | ||||
|             if (!syncServerHost) { | ||||
|                 showAlert("Trilium server address can't be empty"); | ||||
|                 return; | ||||
|             } | ||||
|         if (!username) { | ||||
|             showAlert("Username can't be empty"); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|             if (!username) { | ||||
|                 showAlert("Username can't be empty"); | ||||
|                 return; | ||||
|             } | ||||
|         if (!password) { | ||||
|             showAlert("Password can't be empty"); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|             if (!password) { | ||||
|                 showAlert("Password can't be empty"); | ||||
|                 return; | ||||
|             } | ||||
|         // not using server.js because it loads too many dependencies
 | ||||
|         const resp = await $.post('api/setup/sync-from-server', { | ||||
|             syncServerHost: syncServerHost, | ||||
|             syncProxy: syncProxy, | ||||
|             username: username, | ||||
|             password: password | ||||
|         }); | ||||
| 
 | ||||
|             // not using server.js because it loads too many dependencies
 | ||||
|             const resp = await $.post('api/setup/sync-from-server', { | ||||
|                 syncServerHost: syncServerHost, | ||||
|                 syncProxy: syncProxy, | ||||
|                 username: username, | ||||
|                 password: password | ||||
|             }); | ||||
|         if (resp.result === 'success') { | ||||
|             this.step('sync-in-progress'); | ||||
| 
 | ||||
|             if (resp.result === 'success') { | ||||
|                 this.step('sync-in-progress'); | ||||
|             setInterval(checkOutstandingSyncs, 1000); | ||||
| 
 | ||||
|                 setInterval(checkOutstandingSyncs, 1000); | ||||
| 
 | ||||
|                 hideAlert(); | ||||
|             } | ||||
|             else { | ||||
|                 showAlert('Sync setup failed: ' + resp.error); | ||||
|             } | ||||
|             hideAlert(); | ||||
|         } | ||||
|         else { | ||||
|             showAlert('Sync setup failed: ' + resp.error); | ||||
|         } | ||||
|     }; | ||||
| } | ||||
|  | ||||
| @ -13,10 +13,8 @@ function getStatus() { | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| async function setupNewDocument(req) { | ||||
|     const { username, password, theme } = req.body; | ||||
| 
 | ||||
|     await sqlInit.createInitialDatabase(username, password, theme); | ||||
| async function setupNewDocument() { | ||||
|     await sqlInit.createInitialDatabase(); | ||||
| } | ||||
| 
 | ||||
| function setupSyncFromServer(req) { | ||||
|  | ||||
| @ -12,9 +12,7 @@ function initDocumentOptions() { | ||||
|     optionService.createOption('documentSecret', utils.randomSecureToken(16), false); | ||||
| } | ||||
| 
 | ||||
| function initSyncedOptions(username, password) { | ||||
|     optionService.createOption('username', username, true); | ||||
| 
 | ||||
| function initPassword(username, password) { | ||||
|     optionService.createOption('passwordVerificationSalt', utils.randomSecureToken(32), true); | ||||
|     optionService.createOption('passwordDerivedKeySalt', utils.randomSecureToken(32), true); | ||||
| 
 | ||||
| @ -129,7 +127,7 @@ function getKeyboardDefaultOptions() { | ||||
| 
 | ||||
| module.exports = { | ||||
|     initDocumentOptions, | ||||
|     initSyncedOptions, | ||||
|     initPassword, | ||||
|     initNotSyncedOptions, | ||||
|     initStartupOptions | ||||
| }; | ||||
|  | ||||
| @ -45,9 +45,7 @@ async function initDbConnection() { | ||||
|     dbReady.resolve(); | ||||
| } | ||||
| 
 | ||||
| async function createInitialDatabase(username, password, theme) { | ||||
|     log.info("Creating database schema ..."); | ||||
| 
 | ||||
| async function createInitialDatabase() { | ||||
|     if (isDbInitialized()) { | ||||
|         throw new Error("DB is already initialized"); | ||||
|     } | ||||
| @ -57,9 +55,9 @@ async function createInitialDatabase(username, password, theme) { | ||||
| 
 | ||||
|     let rootNote; | ||||
| 
 | ||||
|     log.info("Creating root note ..."); | ||||
| 
 | ||||
|     sql.transactional(() => { | ||||
|         log.info("Creating database schema ..."); | ||||
| 
 | ||||
|         sql.executeScript(schema); | ||||
| 
 | ||||
|         require("../becca/becca_loader").load(); | ||||
| @ -67,6 +65,8 @@ async function createInitialDatabase(username, password, theme) { | ||||
|         const Note = require("../becca/entities/note"); | ||||
|         const Branch = require("../becca/entities/branch"); | ||||
| 
 | ||||
|         log.info("Creating root note ..."); | ||||
| 
 | ||||
|         rootNote = new Note({ | ||||
|             noteId: 'root', | ||||
|             title: 'root', | ||||
| @ -87,8 +87,7 @@ async function createInitialDatabase(username, password, theme) { | ||||
|         const optionsInitService = require('./options_init'); | ||||
| 
 | ||||
|         optionsInitService.initDocumentOptions(); | ||||
|         optionsInitService.initSyncedOptions(username, password); | ||||
|         optionsInitService.initNotSyncedOptions(true, { theme }); | ||||
|         optionsInitService.initNotSyncedOptions(true, {}); | ||||
|         optionsInitService.initStartupOptions(); | ||||
|     }); | ||||
| 
 | ||||
|  | ||||
| @ -55,62 +55,20 @@ | ||||
|         <div id="setup-type" data-bind="visible: step() == 'setup-type'" style="margin-top: 20px;"> | ||||
|             <div class="radio" style="margin-bottom: 15px;"> | ||||
|                 <label><input type="radio" name="setup-type" value="new-document" data-bind="checked: setupType"> | ||||
|                     I'm a new user and I want to create new Trilium document for my notes</label> | ||||
|                     I'm a new user, and I want to create new Trilium document for my notes</label> | ||||
|             </div> | ||||
|             <div class="radio" style="margin-bottom: 15px;"> | ||||
|                 <label><input type="radio" name="setup-type" value="sync-from-desktop" data-bind="checked: setupType"> | ||||
|                     I have desktop instance already and I want to setup sync with it</label> | ||||
|                     I have desktop instance already, and I want to set up sync with it</label> | ||||
|             </div> | ||||
|             <div class="radio" style="margin-bottom: 15px;"> | ||||
|                 <label><input type="radio" name="setup-type" value="sync-from-server" data-bind="checked: setupType"> | ||||
|                     I have server instance already and I want to setup sync with it</label> | ||||
|                     I have server instance already, and I want to set up sync with it</label> | ||||
|             </div> | ||||
| 
 | ||||
|             <button type="button" data-bind="disable: !setupTypeSelected(), click: selectSetupType" class="btn btn-primary">Next</button> | ||||
|         </div> | ||||
| 
 | ||||
|         <div data-bind="visible: step() == 'new-document'"> | ||||
|             <h2>New document</h2> | ||||
| 
 | ||||
|             <p>You're almost done with the setup. The last thing is to choose username and password using which you'll login to the application. | ||||
|                 This password is also used for generating encryption key which encrypts protected notes.</p> | ||||
| 
 | ||||
|             <div class="form-group"> | ||||
|                 <label for="username">Username</label> | ||||
|                 <input type="text" class="form-control" data-bind="value: username" placeholder="Choose alphanumeric username"> | ||||
|             </div> | ||||
|             <div class="form-group"> | ||||
|                 <label for="password1">Password</label> | ||||
|                 <input type="password" class="form-control" data-bind="value: password1" placeholder="Password"> | ||||
|             </div> | ||||
|             <div class="form-group"> | ||||
|                 <label for="password2">Repeat password</label> | ||||
|                 <input type="password" class="form-control" data-bind="value: password2" placeholder="Password"> | ||||
|             </div> | ||||
|             <div class="form-group"> | ||||
|                 <label for="password2">Theme</label> | ||||
| 
 | ||||
|                 <div style="display: flex; justify-content: space-around;"> | ||||
|                     <div class="form-check form-check-inline"> | ||||
|                         <input class="form-check-input" type="radio" name="theme" id="theme-light" value="light" data-bind="checked: theme" checked> | ||||
|                         <label class="form-check-label" for="theme-light">light</label> | ||||
|                     </div> | ||||
|                     <div class="form-check form-check-inline"> | ||||
|                         <input class="form-check-input" type="radio" name="theme" id="theme-dark" value="dark" data-bind="checked: theme"> | ||||
|                         <label class="form-check-label" for="theme-dark">dark</label> | ||||
|                     </div> | ||||
|                 </div> | ||||
| 
 | ||||
|                 <p style="font-size: smaller;margin-top: 10px;"><em>Theme can be later changed in Options -> Appearance.</em></p> | ||||
|             </div> | ||||
| 
 | ||||
|             <button type="button" data-bind="click: back" class="btn btn-secondary">Back</button> | ||||
| 
 | ||||
|               | ||||
| 
 | ||||
|             <button type="button" data-bind="click: finish" class="btn btn-primary">Finish setup</button> | ||||
|         </div> | ||||
| 
 | ||||
|         <div data-bind="visible: step() == 'new-document-in-progress'"> | ||||
|             <h2>Document initialization in progress</h2> | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam