-
-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check reserved words on creating new content type instances #4486
Comments
@ksuess should I proceed with this issue?? |
@AbhishekCS3459, I updated the issue description. If @plone/volto-team verifies, than you can go with it. |
@ksuess is this issue verified now? |
Yes, you can go for it. Great that you want to implement a solution. In the backend plone.restapi cares to generate a valid id. At least in most cases. In plone.restapi you can see that an id can be passed on content creation: So for the test, please take into account "config.settings.reservedIds" and "config.settings.nonContentRoutes". Please don't hesitate to ask if you have any questions. |
Hello @ksuess , can you please provide me the steps to reproduce the behavior in browser. This will help me understand the code and process. |
@BhuvaneshPatil , please read the issue description. |
Hello @ksuess , I am debugging this behavior, my observation is the field So my solution would be to check the name (title) of page and compare it to all the reserved keywords for URLs in frontend. there are two possibilities -
To get all reserved words we can use I wanted to know one thing - how the name is being converted to id. My general understanding till now from experimenting is - take the name - convert it into lowercase - and replace spaces with or is there any function for the same? I also have one query - |
@BhuvaneshPatil A resource is created with title and some more data, but not a concrete id. At the end, also handle the case that for example "register" two times is tried to use. Then the second "register-1" is not valid, because it is already taken. |
@BhuvaneshPatil Due to the recent changes in Plone repos, I am not sure if you are able to open a new branch. This was until now the recommended way, instead of opening a branch on a fork. Please try to open a branch here in plone/volto. If it's not possible, please let us know. |
Thank you for your reply, I tried sending |
Hello @ksuess , I have implemented the functionality to check the id for first time. For example - One of my solution is to call an API with modified id, in above case it will be - 'register-1`. If it returns 404 then we can safely continue our operation. If it doesn't we notify the user to change the title of page. The drawback of this approach is that, we are giving an extra call for API. To simplify this approach we can use the error thrown by the And show reset the id to undefined, then user will have to change the title. The downside of this approach is bad UX. I will appreciate your inputs and suggestions on the same. |
@BhuvaneshPatil I thought about it now. A bit late, I had to focus on a project. In my opinion, the backend should deal with "Create content with id xy in container, even if an object with this id alreay exists in this container. It is not the frontend that should forsee this problem, I think. Just to be clear: Why the check for reserved words in frontend is necessary, is that some strings like frontend routes, like "register", are not known by the backend. They are configured in frontend only. Let's see the opinions about plone/plone.restapi#1613 … |
As editor I should not be able to create a page "register" in site root. This clashes with the registration form.
The text was updated successfully, but these errors were encountered: