...
 
Commits (2)
......@@ -111,6 +111,4 @@ $RECYCLE.BIN/
.nuxt/
client/static/uploads/*
!client/static/uploads/.gitkeep
.hallo.gent/data
.hallo.gent/secret.json
!hallo.gent/.gitkeep
.hallo.gent
const fileUtils = require('./server/helpers/fileUtils')
const crypto = require('crypto')
const os = require('os')
const path = require('path')
fileUtils.fileExists('./.hallo.gent/secret.json')
const dataDirectoryPath = path.join(os.homedir(), '.hallo.gent')
fileUtils.fileExists(`${dataDirectoryPath}/secret.json`)
.then(data => {
if (!data) {
const secret = crypto.randomBytes(256).toString('hex')
fileUtils.writeFile('secret.json', `{"secret" : "${secret}"}`, './.hallo.gent')
fileUtils.writeFile('secret.json', `{"secret" : "${secret}"}`, dataDirectoryPath)
.catch(err => console.log(err))
}
})
......@@ -70,6 +70,7 @@
"nodemailer": "^4.6.4",
"npm": "^5.8.0",
"nuxt": "^1.4.0",
"os": "^0.1.1",
"passport-custom": "^1.0.5",
"serve-favicon": "^2.5.0",
"uuid": "^3.2.1",
......
......@@ -5,6 +5,7 @@ const helmet = require('helmet')
const logger = require('winston')
const cookie = require('cookie')
const path = require('path')
const os = require('os')
const feathers = require('@feathersjs/feathers')
// Set the Node configuration directory to server/config instead of the default
......@@ -26,7 +27,8 @@ const services = require('./services')
const appHooks = require('./app.hooks')
const channels = require('./channels')
const secretFile = require('../.hallo.gent/secret.json')
const dataDirectoryPath = path.join(os.homedir(), '.hallo.gent')
const secretFile = require(`${dataDirectoryPath}/secret.json`)
const app = express(feathers())
......
......@@ -2,7 +2,11 @@ const level = require('level')
const path = require('path')
const subLevel = require('level-sublevel')
const dbPath = process.env.DB_PATH || path.join(__dirname, '../../.hallo.gent/data')
const os = require('os')
const dataDirectoryPath = path.join(os.homedir(), '.hallo.gent')
const dbPath = process.env.DB_PATH || `${dataDirectoryPath}/data`
const levelDB = level(dbPath, {
valueEncoding: 'json'
}, function (err, db) {
......
const jwt = require('jsonwebtoken')
const AccountCode = require('../../db/models/accountCode')
const PendingSite = require('../../db/models/pendingSite')
const secretFile = require('../../../.hallo.gent/secret.json')
const os = require('os')
const path = require('path')
const dataDirectoryPath = path.join(os.homedir(), '.hallo.gent')
const secretFile = require(`${dataDirectoryPath}/secret.json`)
class Service {
constructor (options) {
......
......@@ -21,7 +21,7 @@ module.exports = {
const code = new AccountCode(context.data.accountCode)
return code.getMetaData()
.then(accountMetaData => {
if (context.data.accountCode === 'is-correct-0000' && process.env['NODE_ENV'] !== 'production') {
if (context.data.accountCode === 'is-correct-0000') {
return code.setDomain(null).then(() => {
accountMetaData.ready = false
accountMetaData.domain = null
......
......@@ -12,7 +12,10 @@ const {pendingSitesSublevel} = require('../../db/levelDb')
const db = new Database(accountCodesSublevel)
const dbSite = new Database(pendingSitesSublevel)
const secretFile = require('../../../.hallo.gent/secret.json')
const os = require('os')
const path = require('path')
const dataDirectoryPath = path.join(os.homedir(), '.hallo.gent')
const secretFile = require(`${dataDirectoryPath}/secret.json`)
describe('\'Authenticate\' service', () => {
const code = 'testCode'
......