Fix #106
@@ -65,7 +65,7 @@ object FindArticleVersions {
|
||||
it.validate().badRequestIfNotValid()
|
||||
|
||||
repo.findVersions(it)
|
||||
.apply { ac.assert { canView(result, citizenOrNull) } }
|
||||
.apply { ac.canView(result, citizenOrNull).assert() }
|
||||
.run {
|
||||
call.respond(
|
||||
toOutput { a: ArticleForListing ->
|
||||
|
||||
@@ -76,7 +76,7 @@ object FindArticles {
|
||||
it.validate().badRequestIfNotValid()
|
||||
|
||||
repo.findArticles(it)
|
||||
.apply { ac.assert { canView(result, citizenOrNull) } }
|
||||
.apply { ac.canView(result, citizenOrNull).assert() }
|
||||
.let {
|
||||
call.respond(
|
||||
it.toOutput {
|
||||
|
||||
@@ -27,7 +27,7 @@ object GetOneArticle {
|
||||
fun Route.getOneArticle(viewRepository: ArticleViewRepository<ArticleForView>, ac: ArticleAccessControl, repo: ArticleRepository) {
|
||||
get<ArticleRequest> {
|
||||
val article: ArticleForView = repo.findById(it.article.id) ?: throw NotFoundException("Article ${it.article.id} not found")
|
||||
ac.assert { canView(article, citizenOrNull) }
|
||||
ac.canView(article, citizenOrNull).assert()
|
||||
|
||||
call.respond(
|
||||
article.let { a ->
|
||||
|
||||
@@ -83,7 +83,7 @@ object UpsertArticle {
|
||||
post<UpsertArticleRequest> {
|
||||
mustBeAuth()
|
||||
val article = call.convertRequestToEntity()
|
||||
ac.assert { canUpsert(article, citizenOrNull) }
|
||||
ac.canUpsert(article, citizenOrNull).assert()
|
||||
repo.upsert(article)?.let { a ->
|
||||
call.respond(
|
||||
object {
|
||||
|
||||
@@ -42,7 +42,7 @@ object ChangeMyPassword {
|
||||
mustBeAuth()
|
||||
val content = call.receiveOrBadRequest<ChangePasswordCitizenRequest.Input>()
|
||||
.apply { validate().badRequestIfNotValid() }
|
||||
ac.assert { canChangePassword(it.citizen, citizenOrNull) }
|
||||
ac.canChangePassword(it.citizen, citizenOrNull).assert()
|
||||
userRepository.findByCredentials(UserPasswordCredential(citizen.user.username, content.oldPassword)) ?: throw BadRequestException("Bad Password")
|
||||
userRepository.changePassword(
|
||||
UserWithPassword(
|
||||
|
||||
@@ -55,7 +55,7 @@ object FindCitizens {
|
||||
mustBeAuth()
|
||||
it.validate().badRequestIfNotValid()
|
||||
val citizens = repo.find(it.page, it.limit, it.sort, it.direction, it.search)
|
||||
ac.assert { canView(citizens.result, citizenOrNull) }
|
||||
ac.canView(citizens.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
citizens.toOutput { c: CitizenCreator ->
|
||||
object {
|
||||
|
||||
@@ -28,7 +28,7 @@ object GetCurrentCitizen {
|
||||
if (currentUser === null) {
|
||||
call.respond(HttpStatusCode.Unauthorized)
|
||||
} else {
|
||||
ac.assert { canView(currentUser, citizenOrNull) }
|
||||
ac.canView(currentUser, citizenOrNull).assert()
|
||||
call.respond(
|
||||
object {
|
||||
val id: UUID = citizen.id
|
||||
|
||||
@@ -29,7 +29,7 @@ object GetOneCitizen {
|
||||
get<CitizenRequest> {
|
||||
mustBeAuth()
|
||||
val citizen = citizenRepository.findById(it.citizen.id) ?: throw NotFoundException("Citizen not found ${it.citizen.id}")
|
||||
ac.assert { canView(citizen, citizenOrNull) }
|
||||
ac.canView(citizen, citizenOrNull).assert()
|
||||
|
||||
call.respond(
|
||||
object {
|
||||
|
||||
@@ -51,7 +51,7 @@ object CreateCommentArticle {
|
||||
content = content
|
||||
)
|
||||
}.let { comment ->
|
||||
ac.assert { canCreate(comment, citizenOrNull) }
|
||||
ac.canCreate(comment, citizenOrNull).assert()
|
||||
repo.comment(comment)
|
||||
|
||||
call.respond(
|
||||
|
||||
@@ -58,7 +58,7 @@ object GetArticleComments {
|
||||
|
||||
val comments = repo.findByTarget(it.article, it.page, it.limit, it.sort)
|
||||
if (comments.result.isNotEmpty()) {
|
||||
ac.assert { canView(comments.result, citizenOrNull) }
|
||||
ac.canView(comments.result, citizenOrNull).assert()
|
||||
}
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
|
||||
@@ -28,7 +28,7 @@ object GetCitizenArticleComments {
|
||||
get<CitizenCommentArticleRequest> {
|
||||
mustBeAuth()
|
||||
repo.findByCitizen(it.citizen).let { comments ->
|
||||
ac.assert { canView(comments.result, citizenOrNull) }
|
||||
ac.canView(comments.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
comments.toOutput { comment ->
|
||||
|
||||
@@ -53,7 +53,7 @@ object CreateConstitutionComment {
|
||||
content = content
|
||||
)
|
||||
}.let { comment ->
|
||||
ac.assert { canCreate(comment, citizenOrNull) }
|
||||
ac.canCreate(comment, citizenOrNull).assert()
|
||||
repo.comment(comment)
|
||||
|
||||
call.respond(
|
||||
|
||||
@@ -28,7 +28,7 @@ object GetCitizenCommentConstitution {
|
||||
get<GetCitizenCommentConstitutionRequest> {
|
||||
mustBeAuth()
|
||||
val comments = repo.findByCitizen(it.citizen)
|
||||
ac.assert { canView(comments.result, citizenOrNull) }
|
||||
ac.canView(comments.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
comments.toOutput { comment ->
|
||||
|
||||
@@ -57,7 +57,7 @@ object GetConstitutionComment {
|
||||
it.validate().badRequestIfNotValid()
|
||||
|
||||
val comments = repo.findByTarget(it.constitution)
|
||||
ac.assert { canView(comments.result, citizenOrNull) }
|
||||
ac.canView(comments.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
comments.toOutput { comment ->
|
||||
|
||||
@@ -54,7 +54,7 @@ object CreateComment {
|
||||
parent = parent,
|
||||
)
|
||||
}.let { newComment ->
|
||||
ac.assert { canCreate(newComment, citizenOrNull) }
|
||||
ac.canCreate(newComment, citizenOrNull).assert()
|
||||
repo.comment(newComment)
|
||||
call.respond(HttpStatusCode.Created, newComment.toOutput())
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ object EditComment {
|
||||
put<EditCommentRequest> {
|
||||
mustBeAuth()
|
||||
val commentOld = repo.findById(it.comment.id) ?: throw NotFoundException("Comment not found")
|
||||
ac.assert { canUpdate(commentOld, citizenOrNull) }
|
||||
ac.canUpdate(commentOld, citizenOrNull).assert()
|
||||
|
||||
call.receiveOrBadRequest<EditCommentRequest.Input>()
|
||||
.apply { validate().badRequestIfNotValid() }
|
||||
|
||||
@@ -39,7 +39,7 @@ object GetCommentChildren {
|
||||
it.limit
|
||||
)
|
||||
|
||||
ac.assert { canView(comments.result, citizenOrNull) }
|
||||
ac.canView(comments.result, citizenOrNull).assert()
|
||||
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
|
||||
@@ -27,7 +27,7 @@ object GetOneComment {
|
||||
fun Route.getOneComment(repo: CommentRepository, ac: CommentAccessControl) {
|
||||
get<CommentRequest> {
|
||||
val comment = repo.findById(it.comment.id) ?: throw NotFoundException("Comment ${it.comment.id} not found")
|
||||
ac.assert { canView(comment, citizenOrNull) }
|
||||
ac.canView(comment, citizenOrNull).assert()
|
||||
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
|
||||
@@ -89,7 +89,7 @@ object CreateConstitution {
|
||||
post<PostConstitutionRequest> {
|
||||
mustBeAuth()
|
||||
getNewConstitution(call.receiveOrBadRequest(), citizen).let {
|
||||
ac.assert { canCreate(it, citizenOrNull) }
|
||||
ac.canCreate(it, citizenOrNull).assert()
|
||||
val c = repo.upsert(it) ?: error("Unable to create Constitution")
|
||||
call.respond(
|
||||
HttpStatusCode.Created,
|
||||
|
||||
@@ -54,7 +54,7 @@ object FindConstitutions {
|
||||
get<FindConstitutionsRequest> {
|
||||
it.validate().badRequestIfNotValid()
|
||||
val constitutions = repo.find(it.page, it.limit, it.sort, it.direction, it.search)
|
||||
ac.assert { canView(constitutions.result, citizenOrNull) }
|
||||
ac.canView(constitutions.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
constitutions.toOutput { c ->
|
||||
|
||||
@@ -27,7 +27,7 @@ object GetConstitution {
|
||||
fun Route.getConstitution(ac: ConstitutionAccessControl, constitutionRepo: ConstitutionRepository) {
|
||||
get<GetConstitutionRequest> {
|
||||
val constitution = constitutionRepo.findById(it.constitution.id) ?: throw NotFoundException("Unable to find constitution ${it.constitution.id}")
|
||||
ac.assert { canView(constitution, citizenOrNull) }
|
||||
ac.canView(constitution, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
constitution.let { c ->
|
||||
|
||||
@@ -28,7 +28,7 @@ object FollowArticle {
|
||||
post<ArticleFollowRequest> {
|
||||
mustBeAuth()
|
||||
val follow = FollowForUpdate(target = it.article, createdBy = this.citizen)
|
||||
ac.assert { canCreate(follow, citizenOrNull) }
|
||||
ac.canCreate(follow, citizenOrNull).assert()
|
||||
repo.follow(follow)
|
||||
call.respond(HttpStatusCode.Created)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ object GetFollowArticle {
|
||||
fun Route.getFollowArticle(repo: FollowArticleRepository, ac: FollowAccessControl) {
|
||||
get<ArticleFollowRequest> {
|
||||
repo.findFollow(citizen, it.article)?.let { follow ->
|
||||
ac.assert { canView(follow, citizenOrNull) }
|
||||
ac.canView(follow, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
follow.toOutput()
|
||||
|
||||
@@ -28,7 +28,7 @@ object GetMyFollowsArticle {
|
||||
get<CitizenFollowArticleRequest> {
|
||||
mustBeAuth()
|
||||
val follows = repo.findByCitizen(it.citizen)
|
||||
ac.assert { canView(follows.result, citizenOrNull) }
|
||||
ac.canView(follows.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
follows.toOutput { f ->
|
||||
|
||||
@@ -28,7 +28,7 @@ object UnfollowArticle {
|
||||
delete<ArticleFollowRequest> {
|
||||
mustBeAuth()
|
||||
val follow = FollowForUpdate(target = it.article, createdBy = this.citizen)
|
||||
ac.assert { canDelete(follow, citizenOrNull) }
|
||||
ac.canDelete(follow, citizenOrNull).assert()
|
||||
repo.unfollow(follow)
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ object FollowCitizen {
|
||||
post<CitizenFollowRequest> {
|
||||
mustBeAuth()
|
||||
val follow = FollowForUpdate(target = it.citizen, createdBy = this.citizen)
|
||||
ac.assert { canCreate(follow, citizenOrNull) }
|
||||
ac.canCreate(follow, citizenOrNull).assert()
|
||||
repo.follow(follow)
|
||||
call.respond(HttpStatusCode.Created)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ object GetFollowCitizen {
|
||||
fun Route.getFollowCitizen(repo: FollowCitizenRepository, ac: FollowAccessControl) {
|
||||
get<CitizenFollowRequest> {
|
||||
repo.findFollow(citizen, it.citizen)?.let { follow ->
|
||||
ac.assert { canView(follow, citizenOrNull) }
|
||||
ac.canView(follow, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
follow.toOutput()
|
||||
|
||||
@@ -28,7 +28,7 @@ object GetMyFollowsCitizen {
|
||||
get<CitizenFollowCitizenRequest> {
|
||||
mustBeAuth()
|
||||
val follows = repo.findByCitizen(it.citizen)
|
||||
ac.assert { canView(follows.result, citizenOrNull) }
|
||||
ac.canView(follows.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
follows.toOutput { f ->
|
||||
|
||||
@@ -28,7 +28,7 @@ object UnfollowCitizen {
|
||||
delete<CitizenFollowRequest> {
|
||||
mustBeAuth()
|
||||
val follow = FollowForUpdate(target = it.citizen, createdBy = this.citizen)
|
||||
ac.assert { canDelete(follow, citizenOrNull) }
|
||||
ac.canDelete(follow, citizenOrNull).assert()
|
||||
repo.unfollow(follow)
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ object FollowConstitution {
|
||||
post<ConstitutionFollowRequest> {
|
||||
mustBeAuth()
|
||||
val follow = FollowForUpdate(target = it.constitution, createdBy = this.citizen)
|
||||
ac.assert { canCreate(follow, citizenOrNull) }
|
||||
ac.canCreate(follow, citizenOrNull).assert()
|
||||
repo.follow(follow)
|
||||
call.respond(HttpStatusCode.Created)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ object GetFollowConstitution {
|
||||
fun Route.getFollowConstitution(repo: FollowConstitutionRepository, ac: FollowAccessControl) {
|
||||
get<ConstitutionFollowRequest> {
|
||||
repo.findFollow(citizen, it.constitution)?.let { follow ->
|
||||
ac.assert { canView(follow, citizenOrNull) }
|
||||
ac.canView(follow, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
follow.toOutput()
|
||||
|
||||
@@ -28,7 +28,7 @@ object GetMyFollowsConstitution {
|
||||
get<CitizenFollowConstitutionRequest> {
|
||||
mustBeAuth()
|
||||
val follows = repo.findByCitizen(it.citizen)
|
||||
ac.assert { canView(follows.result, citizenOrNull) }
|
||||
ac.canView(follows.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
follows.toOutput { f ->
|
||||
|
||||
@@ -28,7 +28,7 @@ object UnfollowConstitution {
|
||||
delete<ConstitutionUnfollowRequest> {
|
||||
mustBeAuth()
|
||||
val follow = FollowForUpdate(target = it.constitution, createdBy = this.citizen)
|
||||
ac.assert { canDelete(follow, citizenOrNull) }
|
||||
ac.canDelete(follow, citizenOrNull).assert()
|
||||
repo.unfollow(follow)
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ object GetCitizenOpinions {
|
||||
get<CitizenOpinions> {
|
||||
mustBeAuth()
|
||||
val opinionsEntities: List<Opinion<ArticleRef>> = repo.findCitizenOpinionsByTargets(it.citizen, it.id)
|
||||
ac.assert { canView(opinionsEntities, citizenOrNull) }
|
||||
ac.canView(opinionsEntities, citizenOrNull).assert()
|
||||
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
|
||||
@@ -55,7 +55,7 @@ object GetMyOpinionsArticle {
|
||||
it.validate().badRequestIfNotValid()
|
||||
|
||||
val opinions: Paginated<Opinion<TargetRef>> = repo.findCitizenOpinions(citizen, it.page, it.limit)
|
||||
ac.assert { canView(opinions.result, citizenOrNull) }
|
||||
ac.canView(opinions.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
opinions.toOutput { it.toOutput() }
|
||||
|
||||
@@ -25,7 +25,7 @@ object GetOpinionChoice {
|
||||
fun Route.getOpinionChoice(ac: OpinionChoiceAccessControl, opinionChoiceRepository: OpinionChoiceRepository) {
|
||||
get<OpinionChoiceRequest> {
|
||||
val opinionChoice = opinionChoiceRepository.findOpinionChoiceById(it.opinionChoice.id) ?: throw NotFoundException("OpinionChoice ${it.opinionChoice.id} not found")
|
||||
ac.assert { canView(it.opinionChoice, citizenOrNull) }
|
||||
ac.canView(it.opinionChoice, citizenOrNull).assert()
|
||||
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
|
||||
@@ -20,7 +20,7 @@ object GetOpinionChoices {
|
||||
fun Route.getOpinionChoices(repo: OpinionChoiceRepository, ac: OpinionChoiceAccessControl) {
|
||||
get<OpinionChoicesRequest> {
|
||||
val opinionChoices = repo.findOpinionsChoices(it.targets)
|
||||
ac.assert { canView(opinionChoices, citizenOrNull) }
|
||||
ac.canView(opinionChoices, citizenOrNull).assert()
|
||||
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
|
||||
@@ -43,7 +43,7 @@ object OpinionArticle {
|
||||
createdBy = citizen
|
||||
)
|
||||
}.let { opinions ->
|
||||
ac.assert { canCreate(opinions, citizenOrNull) }
|
||||
ac.canCreate(opinions, citizenOrNull).assert()
|
||||
repo.updateOpinions(opinions)
|
||||
}.let {
|
||||
call.respond(
|
||||
|
||||
@@ -30,7 +30,7 @@ object GetCitizenVotes {
|
||||
mustBeAuth()
|
||||
val votes = repo.findCitizenVotesByTargets(it.citizen, it.id)
|
||||
if (votes.isNotEmpty()) {
|
||||
ac.assert { canView(votes, citizenOrNull) }
|
||||
ac.canView(votes, citizenOrNull).assert()
|
||||
}
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
|
||||
@@ -49,7 +49,7 @@ object GetCitizenVotesOnArticle {
|
||||
it.validate().badRequestIfNotValid()
|
||||
|
||||
val votes = repo.findByCitizen(it.citizen, it.page, it.limit)
|
||||
ac.assert { canView(votes.result, citizenOrNull) }
|
||||
ac.canView(votes.result, citizenOrNull).assert()
|
||||
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
|
||||
@@ -51,7 +51,7 @@ object PutVoteOnArticle {
|
||||
note = input.note,
|
||||
createdBy = this.citizen
|
||||
)
|
||||
ac.assert { canCreate(vote, citizenOrNull) }
|
||||
ac.canCreate(vote, citizenOrNull).assert()
|
||||
val votes = repo.vote(vote)
|
||||
call.respond(
|
||||
HttpStatusCode.Created,
|
||||
|
||||
@@ -52,7 +52,7 @@ object PutVoteOnComment {
|
||||
note = input.note,
|
||||
createdBy = this.citizen
|
||||
)
|
||||
ac.assert { canCreate(vote, citizenOrNull) }
|
||||
ac.canCreate(vote, citizenOrNull).assert()
|
||||
val votes = voteCommentRepo.vote(vote)
|
||||
call.respond(
|
||||
HttpStatusCode.Created,
|
||||
|
||||
@@ -51,7 +51,7 @@ object PutVoteOnConstitution {
|
||||
note = input.note,
|
||||
createdBy = this.citizen
|
||||
)
|
||||
ac.assert { canCreate(vote, citizenOrNull) }
|
||||
ac.canCreate(vote, citizenOrNull).assert()
|
||||
repo.vote(vote)
|
||||
call.respond(HttpStatusCode.Created)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ object CreateWorkgroup {
|
||||
anonymous ?: true,
|
||||
)
|
||||
}.let { workgroup ->
|
||||
ac.assert { canCreate(workgroup, citizenOrNull) }
|
||||
ac.canCreate(workgroup, citizenOrNull).assert()
|
||||
repo.upsert(workgroup)
|
||||
}.let { w ->
|
||||
call.respond(
|
||||
|
||||
@@ -23,7 +23,7 @@ object DeleteWorkgroup {
|
||||
delete<DeleteWorkgroupRequest> {
|
||||
mustBeAuth()
|
||||
repo.findById(it.workgroupId)?.let { workgroup ->
|
||||
ac.assert { canDelete(workgroup, citizenOrNull) }
|
||||
ac.canDelete(workgroup, citizenOrNull).assert()
|
||||
repo.delete(workgroup)
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
} ?: call.respond(HttpStatusCode.NotFound)
|
||||
|
||||
@@ -65,7 +65,7 @@ object EditWorkgroup {
|
||||
deletedAt = old.deletedAt,
|
||||
members = old.members,
|
||||
).let { workgroup ->
|
||||
ac.assert { canUpdate(workgroup, citizenOrNull) }
|
||||
ac.canUpdate(workgroup, citizenOrNull).assert()
|
||||
repo.upsert(workgroup)
|
||||
}.let {
|
||||
call.respond(HttpStatusCode.OK, it.toOutput())
|
||||
|
||||
@@ -24,7 +24,7 @@ object GetWorkgroup {
|
||||
fun Route.getWorkgroup(repo: WorkgroupRepository, ac: WorkgroupAccessControl) {
|
||||
get<WorkgroupRequest> {
|
||||
repo.findById(it.workgroup.id)?.let { workgroup ->
|
||||
ac.assert { canView(workgroup, citizenOrNull) }
|
||||
ac.canView(workgroup, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
workgroup.toOutput()
|
||||
|
||||
@@ -69,7 +69,7 @@ object GetWorkgroups {
|
||||
it.search,
|
||||
WorkgroupRepository.Filter(createdById = it.createdBy, members = it.members)
|
||||
)
|
||||
ac.assert { canView(workgroups.result, citizenOrNull) }
|
||||
ac.canView(workgroups.result, citizenOrNull).assert()
|
||||
call.respond(
|
||||
HttpStatusCode.OK,
|
||||
workgroups.toOutput { it.toOutputListing() }
|
||||
|
||||
@@ -47,7 +47,7 @@ object AddMemberToWorkgroup {
|
||||
mustBeAuth()
|
||||
repo.findById(it.workgroupId)?.let { workgroup ->
|
||||
call.getMembersFromRequest().let { members ->
|
||||
ac.assert { canAddMembers(workgroup, citizenOrNull) }
|
||||
ac.canAddMembers(workgroup, citizenOrNull).assert()
|
||||
repo.addMembers(workgroup, members)
|
||||
}.let { members ->
|
||||
call.respond(
|
||||
|
||||
@@ -39,7 +39,7 @@ object DeleteMembersOfWorkgroup {
|
||||
repo.findById(it.workgroupId)?.let { workgroup ->
|
||||
call.getMembersFromRequest()
|
||||
.let { members ->
|
||||
ac.assert { canRemoveMembers(workgroup, citizenOrNull) }
|
||||
ac.canRemoveMembers(workgroup, citizenOrNull).assert()
|
||||
repo.removeMembers(workgroup, members)
|
||||
}.let { members ->
|
||||
call.respond(
|
||||
|
||||
@@ -45,7 +45,7 @@ object UpdateMemberOfWorkgroup {
|
||||
mustBeAuth()
|
||||
repo.findById(it.workgroupId)?.let { workgroup ->
|
||||
call.getMembersFromRequest().let { members ->
|
||||
ac.assert { canUpdateMembers(workgroup, citizenOrNull) }
|
||||
ac.canUpdateMembers(workgroup, citizenOrNull).assert()
|
||||
repo.updateMembers(workgroup, members)
|
||||
}.let { members ->
|
||||
call.respond(
|
||||
|
||||
Reference in New Issue
Block a user