Add a publish
access control to disable publish button and only allow to save
versioned documents
#1009
Replies: 3 comments 5 replies
-
Thank you for the feature request! I just had a thought. This may be possible in a better way than adding another On the frontend, we are going to update the way that we execute access control and we could work in a smarter way to determine if someone can publish simply by attempting to execute the existing I think this is a better way to handle this, because then you handle everything in one place. So let's take const restrictEditorsToDraftsOnly: Access = ({ req: { user }, data }) => {
// Only logged in users can create or update
if (user) {
// Let's say we have a 'roles' field
// If the user is an admin, then they can do whatever
if (user.roles.includes('admin')) {
return true;
}
// Otherwise all other users can only create or update
// if they have NOT passed data._status === 'published'
return data._status !== 'published';
}
// Not logged in? No user? Can't do it
return false;
} This is how your access control should be written anyway, so if Payload can smartly reuse this access control function on the frontend to determine if the user can submit What do you think? This would be super seamless. |
Beta Was this translation helpful? Give feedback.
-
Hello! First, congratulations on this project, our team in doing a lot in a short period of time! @jmikrut I am wondering if there is any update in this feature request? Or any work around we could use? Our MVP requires that a creator can create recipe drafts but only an editor can publish them. |
Beta Was this translation helpful? Give feedback.
-
Hey all, this has been completed! if you have access control that limits the update or create operation based on incoming data, say If the access control allows it, great, but if it blocks it, then we know the user can’t publish and then we dynamically hide the publish button for those cases! |
Beta Was this translation helpful? Give feedback.
-
Hi 👋🏻
As discussed in the Discord it could be cool to have a new access control for managing who can publish a document. This way we could create roles such as
editor
andpublisher
with this kind of scenario:editor
can create a document and save it (like blog post) but can't publish to make it live on the website (the button should not be visible ifpublish: () => false
)publisher
can check what theeditor
did (verifying typos, whatever else) and publish the document if everything is good.For further ideas, it will be really useful for creating workflows inside the CMS (like a state machine X has done this, then Y can do that, with notifications like "John finished to write the post "PayloadCMS is amazing!!", could you review and publish?")
Beta Was this translation helpful? Give feedback.
All reactions