mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-21 16:52:00 -07:00
Moved auth library to adapters dir
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ const cors = require('kcors')
|
||||
// Local libraries
|
||||
const config = require('../config') // this first.
|
||||
// const IPFSLib = require('../src/lib/ipfs')
|
||||
const AdminLib = require('../src/lib/admin')
|
||||
const AdminLib = require('../src/adapters/admin')
|
||||
const adminLib = new AdminLib()
|
||||
// const JSONRPC = require('../src/rpc')
|
||||
// const rpc = new JSONRPC()
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
and JWT token for the admin account is written to a JSON file, for easy
|
||||
retrieval by other apps running on the server that may need admin privledges
|
||||
to access private APIs.
|
||||
|
||||
This library is really more of an Adapter to the internal systems default
|
||||
admin user. It's not really a central Entity, which is why this library lives
|
||||
in the Adapter directory.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
@@ -22,6 +22,7 @@ const User = new mongoose.Schema({
|
||||
}
|
||||
})
|
||||
|
||||
// Before saving, convert the password to a hash.
|
||||
User.pre('save', function preSave (next) {
|
||||
const user = this
|
||||
|
||||
@@ -51,6 +52,7 @@ User.pre('save', function preSave (next) {
|
||||
.catch(err => next(err))
|
||||
})
|
||||
|
||||
// Validate the password by comparing to the saved hash.
|
||||
User.methods.validatePassword = function validatePassword (password) {
|
||||
const user = this
|
||||
|
||||
@@ -65,6 +67,7 @@ User.methods.validatePassword = function validatePassword (password) {
|
||||
})
|
||||
}
|
||||
|
||||
// Generate a JWT token.
|
||||
User.methods.generateToken = function generateToken () {
|
||||
const user = this
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ const axios = require('axios').default
|
||||
const config = require('../../../config')
|
||||
const app = require('../../../bin/server')
|
||||
const testUtils = require('../../utils/test-utils')
|
||||
const AdminLib = require('../../../src/lib/admin')
|
||||
const AdminLib = require('../../../src/adapters/admin')
|
||||
const adminLib = new AdminLib()
|
||||
|
||||
// const request = supertest.agent(app.listen())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const assert = require('chai').assert
|
||||
|
||||
const Admin = require('../../../src/lib/admin')
|
||||
const Admin = require('../../../src/adapters/admin')
|
||||
|
||||
const sinon = require('sinon')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user