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

only add author if user exists

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