diff --git a/src/actions/posts.js b/src/actions/posts.js index 8bfbf4ca0e042018084ee89760019cd8cfb83c1b..eab9e29ea28f009003d5faeda852f5764dce310f 100644 --- a/src/actions/posts.js +++ b/src/actions/posts.js @@ -3,7 +3,7 @@ import property from "lodash/property"; import { createAsyncAction, errorResult, successResult } from "pullstate"; import { fetch } from "api"; -import { PostStore } from "stores"; +import { AuthStore, PostStore } from "stores"; import { createSeenWriter, filterPosts, @@ -176,6 +176,21 @@ export const edit = createAsyncAction( } catch (err) { return errorResult([], err.toString()); } + }, + { + shortCircuitHook: ({ args }) => { + const { user } = AuthStore.getRawState(); + + if (!user) { + return errorResult(); + } + + if (user && user.isBanned) { + return errorResult(); + } + + return false; + }, } ); diff --git a/src/components/posts/Post.jsx b/src/components/posts/Post.jsx index 3f178c7a59858df03b8a5af9bf7821209029db78..73505a856bd3e95aa43e7efc2605497e592b2f37 100644 --- a/src/components/posts/Post.jsx +++ b/src/components/posts/Post.jsx @@ -163,7 +163,8 @@ const Post = ({ type === "procedure-proposal" && ["announced", "pending"].includes(state); const showEditAction = - isChairman || (currentUser && currentUser.id === author.id); + isChairman || + (currentUser && currentUser.id === author.id && !currentUser.isBanned); const showBanAction = isChairman && !author.isBanned; const showUnbanAction = isChairman && author.isBanned; const showHideAction = isChairman && !archived;