From 22e6b2b6faa217b3ad5e1b60b009f2495c9dfb0b Mon Sep 17 00:00:00 2001 From: N0str Date: Sat, 9 Dec 2017 00:07:20 +0300 Subject: [PATCH] Revert "Merge pull request #84 from codex-team/user-support" This reverts commit 5b993c1f4a4aa22abe7fe7845810954bf1b9710f, reversing changes made to 192d4c2002ad7a62388930a201f1738884fe68c3. --- index.js | 15 +++------------ models/users.js | 51 ------------------------------------------------- 2 files changed, 3 insertions(+), 63 deletions(-) delete mode 100644 models/users.js diff --git a/index.js b/index.js index c284482c..700284a3 100644 --- a/index.js +++ b/index.js @@ -10,26 +10,17 @@ const BrowserWindow = electron.BrowserWindow; let pkg = require('./package.json'); const DirectoryClass = require('./models/directory'); -const UsersClass = require('./models/users'); const DirectoryControllerClass = require('./controllers/directory'); const NotesControllerClass = require('./controllers/note'); - const db = require('./utils/database'); db.makeInitialSettings(app.getPath('userData')); let Directory = new DirectoryClass(); -let Users = new UsersClass(); - -Users.register().then(function() { - - let directoryCtrl = new DirectoryControllerClass(); - let notesCtrl = new NotesControllerClass(); - -}).catch(function (err) { - console.log("Initialization error", err); -}); +// run controllers +let directoryCtrl = new DirectoryControllerClass(); +let notesCtrl = new NotesControllerClass(); let mainWindow = null; diff --git a/models/users.js b/models/users.js deleted file mode 100644 index 5e25b9e1..00000000 --- a/models/users.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; -const random = require('../utils/random'); -const db = require('../utils/database'); - -/** - * Model for current user representation. - */ -class User { - - constructor() {} - - /** - * Return current user if exists, otherwise create new identity. - * { - * user: { - * user_id - User unique ID - * password - User unique password - * } - * } - * @returns user identity - */ - async register() { - - try { - let user = await this.get(); - if (user) { - return user; - } - - let userId = random.generatePassword(); - let newUser = {"user_id": userId, "name": "user"}; - await db.insert(db.USER, {'user': newUser}); - return newUser; - } - catch (err) { - console.log("User register error: ", err); - } - - } - - /** - * Get current user. - * @returns {*} - */ - async get() { - return await db.findOne(db.USER, { "user": { $exists: true } }); - } - -} - -module.exports = User; \ No newline at end of file