Release 1773
Trello card
Context
Before accepting the cookies, we store the HTTP referer, in order to redirect the users back to the page they were at. However there are cases where the referer is not a GET path, causing 404s because there's nothing to render.
Changes proposed in this pull request
- Set the redirect link to root path when the referer is not recognised as a GET resource
It's utilising the Rails.application.routes.recognize_path()
which by default tries to recognise GET paths. If a route is found, then we assume it's safe to redirect to, otherwise the homepage is used as a fallback.
- Remove the
cookies_policy
from the REFERER_BLACKLIST.
Accepting the cookies from the /cookies_policy
page, will now keep the users on the same page and won't redirect them to the edit cookies page.
- Rename the misspelled
save_refererer
method tosave_referer
.
Guidance to review
The 404 can be reproduced with the following steps:
- open https://schoolexperience.education.gov.uk/candidates/feedbacks/new in incognito (or clear the cookies)
- click
Submit feedback
(with empty form) - click
Accept cookies
at the top of the page