Skip to content

Commit

Permalink
Only show 'edit' on published pages when viewer is the owner. Shared
Browse files Browse the repository at this point in the history
pages don't grant edit permissions, so this is good enough.  All actual
security is enforced in the API, so this just displays (or not) the
UI.
  • Loading branch information
dannon committed Sep 12, 2023
1 parent cd50265 commit 9310245
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client/src/components/PageDisplay/PageDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:enable_beta_markdown_export="config.enable_beta_markdown_export"
:download-endpoint="stsUrl(config)"
:export-link="exportUrl"
:read-only="!userOwnsPage"
@onEdit="onEdit" />
<PageHtml v-else :page="page" />
</div>
Expand All @@ -25,6 +26,8 @@ import ConfigProvider from "components/providers/ConfigProvider";
import Markdown from "components/Markdown/Markdown";
import Published from "components/Common/Published";
import PageHtml from "./PageHtml";
import { mapState } from "pinia";
import { useUserStore } from "@/stores/userStore";
export default {
components: {
Expand All @@ -45,6 +48,10 @@ export default {
};
},
computed: {
...mapState(useUserStore, ["currentUser"]),
userOwnsPage() {
return this.currentUser.username === this.page.username;
},
dataUrl() {
return `/api/pages/${this.pageId}`;
},
Expand Down

0 comments on commit 9310245

Please sign in to comment.