Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CD-CODE Web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CD-CODE team
CD-CODE Web
Commits
a1cf5212
Commit
a1cf5212
authored
3 years ago
by
moon
Browse files
Options
Downloads
Patches
Plain Diff
Added security checks for normal user, contributor and maintainer
parent
c427cedc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cms/src/api/update-item/controllers/update-item.js
+13
-6
13 additions, 6 deletions
cms/src/api/update-item/controllers/update-item.js
with
13 additions
and
6 deletions
cms/src/api/update-item/controllers/update-item.js
+
13
−
6
View file @
a1cf5212
...
...
@@ -15,14 +15,20 @@ module.exports = createCoreController('api::update-item.update-item', ({ strapi
},
async
update
(
ctx
)
{
// console.log(ctx.state.user.role.name);
let
response
;
switch
(
ctx
.
state
.
user
.
role
.
name
)
{
case
'
Public
'
:
case
'
Authenticated
'
:
case
'
Contributor
'
:
// Remove operation should be intact
ctx
.
request
.
body
.
data
.
updatedBy
=
ctx
.
state
.
user
.
id
;
ctx
.
request
.
body
.
data
.
UpdateSubmissionTimestamp
=
new
Date
();
if
(
ctx
.
request
.
body
.
data
.
submittedBy
.
id
!==
ctx
.
state
.
user
.
id
)
{
const
sanitizedEntity
=
await
this
.
sanitizeOutput
(
null
,
ctx
);
response
=
this
.
transformResponse
(
sanitizedEntity
);
}
else
{
ctx
.
request
.
body
.
data
.
updatedBy
=
ctx
.
state
.
user
.
id
;
ctx
.
request
.
body
.
data
.
UpdateSubmissionTimestamp
=
new
Date
();
response
=
await
super
.
update
(
ctx
);
}
break
;
case
'
Maintainer
'
:
...
...
@@ -32,12 +38,13 @@ module.exports = createCoreController('api::update-item.update-item', ({ strapi
// Apply review operation
// const entity = await strapi.service('api::update-item.update-item').findOne(ctx.params.id);
// console.log(entity);
ctx
.
request
.
body
.
data
.
reviewedBy
=
ctx
.
state
.
user
.
id
;
ctx
.
request
.
body
.
data
.
UpdateReviewTimestamp
=
new
Date
();
ctx
.
request
.
body
.
data
.
updatedBy
=
ctx
.
state
.
user
.
id
;
ctx
.
request
.
body
.
data
.
UpdateSubmissionTimestamp
=
new
Date
();
response
=
await
super
.
update
(
ctx
);
break
;
}
return
super
.
update
(
ctx
)
;
return
response
;
},
// This updateReview function is called by only either Maintainer or Administrator
async
updateReview
(
ctx
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment