Commit b36737aa authored by A. Koch's avatar A. Koch

fix author and profile flow

parent fe4b08bc
......@@ -29,7 +29,7 @@ class Service extends TinyEmitter {
async findHandler (req, res) {
let results = await this._client.find(JSON.parse(req.query.query || '{}'), req.params)
const userId = req.user ? req.user.uuid : 'anon'
const roles = req.user ? req.user[`${config.api.auth0AppMetadataPrefix}roles`] || [] : []
const roles = req.user ? req.user.profile[`${config.api.auth0AppMetadataPrefix}roles`] || [] : []
const items = []
for (let entry of results) {
let allowed = false
......
const { ObjectUtil } = require('mbjs-utils')
const setup = async function (api, profileService) {
api.app.use(async (req, res, next) => {
if (req.user) {
......@@ -7,7 +9,8 @@ const setup = async function (api, profileService) {
},
user: req.user
}
req.user.profile = await profileService.getHandler(r)
const result = await profileService.getHandler(r)
req.user.profile = ObjectUtil.merge({}, req.user.profile, result.data)
if (req.method.toLowerCase() === 'post') {
req.body.author = {
id: req.user.uuid,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment