Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

refactor: move session validation to its fn

thecodrr2218798ab4d2
diff --git a/packages/core/api/index.js b/packages/core/api/index.js
index b6dd84ecc..d3f4f6bfa 100644
--- a/packages/core/api/index.js
+++ b/packages/core/api/index.js
@@ -18,15 +18,19 @@ class Database {
this._syncInterval = 0;
}
- async init() {
- this.session = new Session();
+ async _validate() {
if (!(await this.session.valid())) {
throw new Error(
"Your system clock is not setup correctly. Please adjust your date and time and then retry."
);
}
+ await this.session.set();
+ }
+
+ async init() {
+ this.session = new Session();
+ this._validate();
- await this.context.write("t", Date.now());
this.user = new User(this);
this.syncer = new Sync(this);
this.vault = new Vault(this);