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

only add author if user exists

parent 6590640f
const setup = async function (api, profileService) { const setup = async function (api, profileService) {
api.app.use(async (req, res, next) => { api.app.use(async (req, res, next) => {
const r = { if (req.user) {
params: { const r = {
id: req.user.uuid params: {
}, id: req.user.uuid
user: req.user },
} user: req.user
req.user.profile = await profileService.getHandler(r) }
if (req.method.toLowerCase() === 'post') { req.user.profile = await profileService.getHandler(r)
req.body.author = { if (req.method.toLowerCase() === 'post') {
id: req.user.uuid, req.body.author = {
name: req.user.profile ? req.user.profile.name : undefined id: req.user.uuid,
name: req.user.profile ? req.user.profile.name : undefined
}
} }
} }
next() next()
......
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