Moved auth library to adapters dir

This commit is contained in:
Chris Troutner
2021-07-07 17:04:19 -07:00
parent 67c5f553b6
commit 36791231cc
5 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -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'
+3
View File
@@ -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
+1 -1
View File
@@ -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 -1
View File
@@ -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')