fix: variable operator id variable name

This commit is contained in:
José Oliveira 2021-11-22 11:31:56 +00:00
parent bca6e15356
commit 3c38dacdc7
3 changed files with 6 additions and 4 deletions

View file

@ -2,8 +2,8 @@ const { getOperatorId } = require('../operator')
function findOperatorId (req, res, next) { function findOperatorId (req, res, next) {
return getOperatorId('middleware') return getOperatorId('middleware')
.then(({ id }) => { .then(({ operatorId }) => {
res.locals.operatorId = id res.locals.operatorId = operatorId
return next() return next()
}) })
.catch(e => { .catch(e => {

View file

@ -10,13 +10,13 @@ const { getOperatorId } = require('../../operator')
const hostname = options.hostname const hostname = options.hostname
router.use('*', async () => { router.use('*', async () => {
return getOperatorId('authentication').then(secret => session({ return getOperatorId('authentication').then(({ operatorId }) => session({
store: new PgSession({ store: new PgSession({
pgPromise: db, pgPromise: db,
tableName: USER_SESSIONS_TABLE_NAME tableName: USER_SESSIONS_TABLE_NAME
}), }),
name: 'lamassu_sid', name: 'lamassu_sid',
secret: secret, secret: operatorId,
resave: false, resave: false,
saveUninitialized: false, saveUninitialized: false,
cookie: { cookie: {

View file

@ -1,8 +1,10 @@
const db = require('./db') const db = require('./db')
const _ = require('lodash/fp')
function getOperatorId (service) { function getOperatorId (service) {
const sql = `SELECT operator_id FROM operator_ids WHERE service = '${service}'` const sql = `SELECT operator_id FROM operator_ids WHERE service = '${service}'`
return db.oneOrNone(sql) return db.oneOrNone(sql)
.then(_.mapKeys(_.camelCase))
} }
module.exports = { getOperatorId } module.exports = { getOperatorId }