Skip to content

Commit

Permalink
#1264 Move permission check from service to controller
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Mar 11, 2021
1 parent 6066a58 commit dceb673
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ class CaseCtrl @Inject() (
entrypoint("delete a custom field")
.authPermittedTransaction(db, Permissions.manageCase) { implicit request => implicit graph =>
for {
_ <-
caseSrv
.caseCustomFieldSrv
.get(EntityIdOrName(cfId))
.filter(_.outV.v[Case].can(Permissions.manageCase))
.existsOrFail
_ <- caseSrv.deleteCustomField(EntityIdOrName(cfId))
} yield Results.NoContent
}
Expand Down
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/services/CaseSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class CaseSrv @Inject() (
Try(
caseCustomFieldSrv
.get(cfIdOrName)
.filter(_.outV.v[Case].can(Permissions.manageCase))
.filter(_.outV.v[Case])
.remove()
)

Expand Down

0 comments on commit dceb673

Please sign in to comment.