From 0c11eb4b559eff3d2086f278e746fcf34db40cac Mon Sep 17 00:00:00 2001 From: bill bittner Date: Thu, 26 Oct 2017 12:49:06 -0700 Subject: [PATCH] switched session key to env var, added thumbnail to Claim upsert on publish --- config/custom-environment-variables.json | 3 +++ config/default.json | 3 +++ controllers/publishController.js | 13 +++++++------ speech.js | 3 +-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index 2ee10c42..78faebbf 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -8,5 +8,8 @@ }, "Logging": { "SlackWebHook": "SLACK_WEB_HOOK" + }, + "Session": { + "SessionKey": "SESSION_KEY" } } \ No newline at end of file diff --git a/config/default.json b/config/default.json index e094bc44..c5b65a20 100644 --- a/config/default.json +++ b/config/default.json @@ -16,5 +16,8 @@ "SlackWebHook": null, "SlackErrorChannel": null, "SlackInfoChannel": null + }, + "Session": { + "SessionKey": null } } \ No newline at end of file diff --git a/controllers/publishController.js b/controllers/publishController.js index 78bc392f..84c68750 100644 --- a/controllers/publishController.js +++ b/controllers/publishController.js @@ -13,16 +13,16 @@ module.exports = { .then(tx => { logger.info(`Successfully published ${fileName}`, tx); publishResults = tx; - return db.Channel.findOne({where: {channelName: publishParams.channel_name}}); + return db.Channel.findOne({where: {channelName: publishParams.channel_name}}); // note: should this be db.User ?? }) - .then(user => { + .then(channel => { let certificateId; - if (user) { - certificateId = user.channelClaimId; - logger.debug('successfully found user in User table'); + if (channel) { + certificateId = channel.channelClaimId; + logger.debug('successfully found channel in Channel table'); } else { certificateId = null; - logger.debug('user for publish not found in User table'); + logger.debug('channel for publish not found in Channel table'); }; const fileRecord = { name : publishParams.name, @@ -43,6 +43,7 @@ module.exports = { title : publishParams.metadata.title, description: publishParams.metadata.description, address : publishParams.claim_address, + thumbnail : publishParams.metadata.thumbnail, outpoint : `${publishResults.txid}:${publishResults.nout}`, height : 0, contentType: fileType, diff --git a/speech.js b/speech.js index 3ad375d8..b6e00a7b 100644 --- a/speech.js +++ b/speech.js @@ -14,7 +14,6 @@ const PORT = 3000; // set port const app = express(); // create an Express application const db = require('./models'); // require our models for syncing const passport = require('passport'); -// const session = require('express-session'); const cookieSession = require('cookie-session'); // configure logging @@ -43,7 +42,7 @@ app.use((req, res, next) => { // custom logging middleware to log all incoming // initialize passport app.use(cookieSession({ name : 'session', - keys : ['testcatstest'], + keys : [config.get('Session.SessionKey')], maxAge: 24 * 60 * 60 * 1000, // 24 hours })); app.use(passport.initialize());