started to think about how ima do notes and groups

This commit is contained in:
plane000
2018-09-08 15:48:56 +01:00
parent e1e036da80
commit 9a16dd2292
6 changed files with 218 additions and 5 deletions

View File

@@ -29,6 +29,6 @@ export class Database extends BaseDatabase {
Database.users = require('./users').UserTools;
Database.auth = require('./tokens').TokenTools;
Database.permalink = require('./permaLink').PermaLinkTools;
Database.permalink = require('./permalinks').PermaLinkTools;
Database.notegroup = require('./notegroups').NoteGroupTools;
Database.note = require('./notes').NoteTools;

View File

@@ -0,0 +1,3 @@
export class Groups {
}

View File

@@ -0,0 +1,5 @@
import {Groups} from './groups';
export class Notes extends Groups {
}

View File

@@ -6,9 +6,10 @@ import {Logger} from '../logger';
export class Password extends User {
static async gen(passwordSecret) {
let prehash = await sha256(passwordSecret);
let toHash = Buffer.from(prehash).toString('base64');
let salt = await bcrypt.genSaltSync(10);
let prehash = await sha256(passwordSecret)
let hash = await bcrypt.hashSync(prehash, salt);
let hash = await bcrypt.hashSync(toHash, salt);
return hash;
}
@@ -16,10 +17,12 @@ export class Password extends User {
static async compare(password, hashToCompare) {
try {
let prehash = await sha256(password);
let res = await bcrypt.compareSync(prehash, hashToCompare);
let toHash = Buffer.from(prehash).toString('base64');
let res = await bcrypt.compareSync(toHash, hashToCompare);
return res;
} catch (e) {
Logger.error(`Somthing went wrong with comparing password hashes: ${e}`);
Logger.error(`Somthing went wrong with comparing hashes: ${e}`);
}
}
}