switched session key to env var, added thumbnail to Claim upsert on publish

This commit is contained in:
bill bittner 2017-10-26 12:49:06 -07:00
parent 426b605acb
commit 0c11eb4b55
4 changed files with 14 additions and 8 deletions

View file

@ -8,5 +8,8 @@
},
"Logging": {
"SlackWebHook": "SLACK_WEB_HOOK"
},
"Session": {
"SessionKey": "SESSION_KEY"
}
}

View file

@ -16,5 +16,8 @@
"SlackWebHook": null,
"SlackErrorChannel": null,
"SlackInfoChannel": null
},
"Session": {
"SessionKey": null
}
}

View file

@ -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,

View file

@ -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());