Skip to content
Snippets Groups Projects
Commit e060ae5e authored by xaralis's avatar xaralis
Browse files

feat: do not allow banned users to edit their posts

parent 35b9dd80
No related branches found
No related tags found
No related merge requests found
Checking pipeline status
......@@ -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;
},
}
);
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment