Skip to content

Commit

Permalink
#1803 Set "_update*" property when an user is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Mar 4, 2021
1 parent b57ef4e commit ab6f660
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions thehive/app/org/thp/thehive/controllers/v1/UserCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import play.api.http.HttpEntity
import play.api.libs.json.{JsNull, JsObject, Json}
import play.api.mvc._

import java.util.Base64
import java.util.{Base64, Date}
import javax.inject.{Inject, Singleton}
import scala.util.{Failure, Success, Try}

Expand Down Expand Up @@ -209,10 +209,19 @@ class UserCtrl @Inject() (
.flatMap(userSrv.setAvatar(user, _))
.map(_ => Json.obj("avatar" -> "[binary data]"))
}.flip
} yield updateName.getOrElse(JsObject.empty) ++
updateLocked.getOrElse(JsObject.empty) ++
updateProfile.getOrElse(JsObject.empty) ++
updatedAvatar.getOrElse(JsObject.empty)
} yield {
val updatedProperties = updateName.getOrElse(JsObject.empty) ++
updateLocked.getOrElse(JsObject.empty) ++
updateProfile.getOrElse(JsObject.empty) ++
updatedAvatar.getOrElse(JsObject.empty)
if (updatedProperties.fields.nonEmpty)
userSrv
.get(user)
.update(_._updatedBy, Some(request.userId))
.update(_._updatedAt, Some(new Date))
.iterate()
updatedProperties
}
}(update => auditSrv.user.update(user, update))
.map(_ => Results.NoContent)
}
Expand Down

0 comments on commit ab6f660

Please sign in to comment.