From 29999bc2ce17b21f7de2e3a8cd2a0d6307f40f6b Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Fri, 25 Jun 2021 19:43:14 +1000 Subject: [PATCH] Allow admins to edit parts Needed for moderation --- app/api/src/lib/owner.js | 3 +++ app/web/src/components/PartProfile/PartProfile.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/api/src/lib/owner.js b/app/api/src/lib/owner.js index e6b934e..7a03bbc 100644 --- a/app/api/src/lib/owner.js +++ b/app/api/src/lib/owner.js @@ -12,6 +12,9 @@ export const requireOwnership = async ({ userId, userName, partId } = {}) => { } if (context.currentUser.roles?.includes('admin')) { + if (context.currentUser?.sub === '5cea3906-1e8e-4673-8f0d-89e6a963c096') { + throw new ForbiddenError("That's a local admin ONLY.") + } return } diff --git a/app/web/src/components/PartProfile/PartProfile.js b/app/web/src/components/PartProfile/PartProfile.js index 222a47b..4159333 100644 --- a/app/web/src/components/PartProfile/PartProfile.js +++ b/app/web/src/components/PartProfile/PartProfile.js @@ -27,7 +27,7 @@ const PartProfile = ({ const [isInvalid, setIsInvalid] = useState(false) const { currentUser } = useAuth() const editorRef = useRef(null) - const canEdit = currentUser?.sub === userPart.id + const canEdit = currentUser?.sub === userPart.id || currentUser?.roles.includes('admin') const isImageEditable = !isEditable && canEdit // image is editable when not in profile edit mode in order to separate them as it's too hard too to upload an image to cloudinary temporarily until the use saves (and maybe have to clean up) for the time being const part = userPart?.Part const emotes = countEmotes(part?.Reaction)