Skip to content
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

Refactor Site ID Verification to Use Admins Sites Table and Fix Broken Revert Feature by Replacing link_to Helper with button_to #922

Merged
merged 3 commits into from
Mar 6, 2025

Conversation

jaredblumer
Copy link
Contributor

@jaredblumer jaredblumer commented Mar 6, 2025

Description

This PR refactors site ID verification by replacing the site_id parameter check with a direct lookup in the admins_sites table, where user site access is stored.

Additionally, this pull request replaces the link_to helper with button_to in the Previous Versions partial to ensure the correct HTTP method is used. Previously, link_to began forcing a GET request, but button_to generates a form that submits a POST request with "_method"=>"put" that overrides the request method to PUT in Rails. To avoid the button forms conflicting with the main page form, the Previous Versions partial is now rendered outside of it.

This pull request also fixes a bug wherein the Save and Continue button was redirecting users to the Content page due to the Save and Continue button missing the site_id parameter. The site ID refactor resolves this issue.

Because the site ID verification within the edit page view no longer uses the site_id parameter, this was removed in the Content nodes and the Page Search nodes. The site_id parameter is still used when selecting a site from the multisite dropdown.

Testing

Site ID Verification

  1. In the Admin panel, identify a site and open a page.
  2. Copy the page's URL.
  3. Navigate to Settings > Users and remove your user’s access to the selected site.
  4. Attempt to visit the copied URL. You should be redirected to the content of a permitted site.

Page Version Revert

  1. Open a page and make a change.
  2. In the Previous Versions dropdown, select an earlier version.
  3. The page should display the content from the selected previous version, reflecting how it appeared before your edits.

Save and Continue

  1. Open a page and make a change.
  2. Select Save and Continue.
  3. You should be redirected back to the edit page view with your changes saved.

Move the previous version partial outside the page form to avoid conflicting with form submitting. The button_to helper generates a form and using this inside another form causes issues.
@jaredblumer jaredblumer changed the title Refactor Site ID verification to Use Admins Sites Table and Fix Broken Revert Feature by Replacing link_to Helper with button_to Refactor Site ID Verification to Use Admins Sites Table and Fix Broken Revert Feature by Replacing link_to Helper with button_to Mar 6, 2025
@jaredblumer jaredblumer marked this pull request as ready for review March 6, 2025 19:42
@danigirl329 danigirl329 merged commit c327c34 into master Mar 6, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants