Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Motion Bank
Services
Motion Bank API
Commits
c238cb45
Commit
c238cb45
authored
Aug 21, 2018
by
A. Koch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only add author if user exists
parent
6590640f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
src/middleware/author.js
src/middleware/author.js
+13
-11
No files found.
src/middleware/author.js
View file @
c238cb45
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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment