started to think about how ima do notes and groups
This commit is contained in:
@@ -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;
|
||||
|
||||
Binary file not shown.
3
src/models/notes/groups.js
Normal file
3
src/models/notes/groups.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export class Groups {
|
||||
|
||||
}
|
||||
5
src/models/notes/notes.js
Normal file
5
src/models/notes/notes.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import {Groups} from './groups';
|
||||
|
||||
export class Notes extends Groups {
|
||||
|
||||
}
|
||||
@@ -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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user