Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix: permission check for cloning board #5853

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 8 additions & 1 deletion src/components/navigation/AppNavigationBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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 @@ -148,6 +148,9 @@ import ClickOutside from 'vue-click-outside'
import ArchiveIcon from 'vue-material-design-icons/Archive.vue'
import CloneIcon from 'vue-material-design-icons/ContentDuplicate.vue'
import AccountIcon from 'vue-material-design-icons/Account.vue'
import { loadState } from '@nextcloud/initial-state'

const canCreateState = loadState('deck', 'canCreate')

export default {
name: 'AppNavigationBoard',
Expand Down Expand Up @@ -185,6 +188,7 @@ export default {
editColor: '',
isDueSubmenuActive: false,
updateDueSetting: null,
canCreate: canCreateState,
}
},
computed: {
Expand Down Expand Up @@ -253,6 +257,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
Loading