beginning of #98, new multistep wizard, db creation after user enters username and password

This commit is contained in:
azivner
2018-07-21 08:55:24 +02:00
parent 3972c27e7a
commit 6235a3c886
8 changed files with 167 additions and 90 deletions

View File

@@ -1,10 +1,5 @@
const repository = require('./repository');
const utils = require('./utils');
const dateUtils = require('./date_utils');
const appInfo = require('./app_info');
async function getOption(name) {
const option = await repository.getOption(name);
const option = await require('./repository').getOption(name);
if (!option) {
throw new Error("Option " + name + " doesn't exist");
@@ -14,7 +9,7 @@ async function getOption(name) {
}
async function setOption(name, value) {
const option = await repository.getOption(name);
const option = await require('./repository').getOption(name);
if (!option) {
throw new Error(`Option ${name} doesn't exist`);
@@ -36,32 +31,8 @@ async function createOption(name, value, isSynced) {
}).save();
}
async function initOptions(startNotePath) {
await createOption('documentId', utils.randomSecureToken(16), false);
await createOption('documentSecret', utils.randomSecureToken(16), false);
await createOption('username', '', true);
await createOption('passwordVerificationHash', '', true);
await createOption('passwordVerificationSalt', '', true);
await createOption('passwordDerivedKeySalt', '', true);
await createOption('encryptedDataKey', '', true);
await createOption('encryptedDataKeyIv', '', true);
await createOption('startNotePath', startNotePath, false);
await createOption('protectedSessionTimeout', 600, true);
await createOption('noteRevisionSnapshotTimeInterval', 600, true);
await createOption('lastBackupDate', dateUtils.nowDate(), false);
await createOption('dbVersion', appInfo.dbVersion, false);
await createOption('lastSyncedPull', appInfo.dbVersion, false);
await createOption('lastSyncedPush', 0, false);
await createOption('zoomFactor', 1.0, false);
await createOption('theme', 'white', false);
}
module.exports = {
getOption,
setOption,
initOptions
createOption
};