Inserting user ID to PostGraphile if available.

This commit is contained in:
DebaucheryLibrarian 2021-03-15 04:16:32 +01:00
parent 8e06d465cb
commit 7c7b38e869
1 changed files with 7 additions and 0 deletions

View File

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