Repository navigation
Require the Create action when saving a create form - #1014
Merged
Merged
Conversation
These forms require the Create action to open, but saving them checked Edit. A customer group allowed to create but not to edit was shown the form and then denied on save. Discounts, gift vouchers and customers already use Create on both sides. The new test covers every Admin and AdminShared action whose form requires Create, so a new action cannot drift from its form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: bugfix
Issue
A create form requires the
Createaction to open, but 19 actions checkEditwhen the form is saved. A customer group allowed to create but not to edit gets the form, fills it in, and is denied on save. The permission screen also does not do what it says: the two actions cannot be set independently for these entities.Discounts, gift vouchers, customers, stores and several others already use
Createon both sides.Solution
Saving a form now requires the action its form requires. The attribute changes on the POST of:
BaseBlogController(Create,CategoryCreate),BaseBrandController,BaseCategoryController,BaseCollectionController,BaseNewsController,BasePageController,BaseProductControllerandBaseShipmentController(AddShipment), shared by the panelsAffiliateController,CampaignController,CourseController(Create,CreateLesson),CustomerGroupController,DocumentController(CreateDocument,CreateType),KnowledgebaseController(CreateCategory,CreateArticle) andVendorControllerin AdminPopups that add a child record to an entity being edited, such as attribute values and tier prices, stay as they are: their form and their POST both use
Edit.CreateActionPermissionTestschecks every Admin and AdminShared action whose form requiresCreate, so a new action cannot drift from its form.No new resources, settings or migrations.
Breaking changes
A plugin or client that posts directly to one of these actions now needs the
Createaction instead ofEdit. Anyone who can open the form can still save it, because both sides now check the same action. URLs and signatures are unchanged.Testing
Unit tests pass:
Grand.Web.Admin.Tests(1840),Grand.Web.Store.Tests(188),Grand.Web.Vendor.Tests(53). The new test fails without the attribute changes. The steps below were not run in a browser./Admin/Permission/Indexand open the actions of the categories permission for a staff customer group.Editand allowCreate,ListandPreview.Editand denyCreatefor the same group.