Skip to content

Commit

Permalink
fix: permission check for cloning board
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <luka@nextcloud.com>

[skip ci]
  • Loading branch information
luka-nextcloud authored and backportbot[bot] committed May 6, 2024
1 parent f5b0077 commit f500328
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/Service/BoardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ public function deleteAcl(int $id): ?Acl {
public function clone($id, $userId) {
$this->boardServiceValidator->check(compact('id', 'userId'));

if (!$this->permissionService->canCreate()) {
throw new NoPermissionException('Creating boards has been disabled for your account.');
}

$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);

$board = $this->boardMapper->find($id);
Expand Down
6 changes: 5 additions & 1 deletion src/components/navigation/AppNavigationBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
@click="actionEdit">
{{ t('deck', 'Edit board') }}
</NcActionButton>
<NcActionButton v-if="canManage && !board.archived"
<NcActionButton v-if="canCreate && !board.archived"
:close-after-click="true"
@click="actionClone">
<template #icon>
Expand Down Expand Up @@ -185,6 +185,7 @@ export default {
editColor: '',
isDueSubmenuActive: false,
updateDueSetting: null,
canCreate: canCreateState,
}
},
computed: {
Expand Down Expand Up @@ -253,6 +254,9 @@ export default {
try {
const newBoard = await this.$store.dispatch('cloneBoard', this.board)
this.loading = false
if (newBoard instanceof Error) {
throw newBoard
}
this.$router.push({ name: 'board', params: { id: newBoard.id } })
} catch (e) {
OC.Notification.showTemporary(t('deck', 'An error occurred'))
Expand Down

0 comments on commit f500328

Please sign in to comment.