From 7c7b38e8699c6ae9e9a5e5d23322f08b5cb3be3f Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 15 Mar 2021 04:16:32 +0100 Subject: [PATCH] Inserting user ID to PostGraphile if available. --- src/web/postgraphile.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/web/postgraphile.js b/src/web/postgraphile.js index d7158916..e9056420 100644 --- a/src/web/postgraphile.js +++ b/src/web/postgraphile.js @@ -12,6 +12,12 @@ const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins const connectionString = `postgres://${config.database.query.user}:${config.database.query.password}@${config.database.query.host}:5432/${config.database.query.database}`; +async function pgSettings(req) { + return { + 'user.id': req.session.user?.id, + }; +} + module.exports = postgraphile( connectionString, 'public', @@ -37,4 +43,5 @@ module.exports = postgraphile( ...ReleasePlugins, ], }, + pgSettings, );