added document_secret as basis for API authentication

This commit is contained in:
azivner
2017-10-28 19:55:55 -04:00
parent 724f4b43b7
commit eb6f9f8f81
7 changed files with 57 additions and 24 deletions

View File

@@ -149,7 +149,15 @@ async function putChanged(changed) {
}
async function putNote(note) {
await sql.insert("notes", note.detail, true);
const origNote = await sql.getSingleResult();
if (origNote !== null && origNote.date_modified >= note.detail.date_modified) {
// version we have in DB is actually newer than the one we're getting from sync
// so we'll leave the current state as it is. The synced version should be stored in the history
}
else {
await sql.insert("notes", note.detail, true);
}
await sql.remove("images", note.detail.note_id);
@@ -168,22 +176,6 @@ async function putNote(note) {
log.info("Update/sync note " + note.detail.note_id);
}
let documentIdCache = null;
async function getDocumentId() {
if (!documentIdCache) {
documentIdCache = await sql.getOption('document_id');
if (!documentIdCache) {
documentIdCache = utils.randomString(16);
await sql.setOption('document_id', documentIdCache);
}
}
return documentIdCache;
}
if (SYNC_SERVER) {
log.info("Setting up sync");