Closed SnowySailor closed 4 years ago
Intercept the error here and do something with it https://github.com/derpibooru/philomena/blob/5f9e9d98a69cb560e9e10f938ce112399b611294/assets/js/ujs.js#L51-L62
This will probably also happen if the captcha is filled out but it's incorrect. We can probably catch some of the cases on the client side like if they didn't fill it out but there will need to be a server side component to this fix as well.
The server side component would need to be rendering text with the appropriate error code (so that the flash stays persisted) and the client side would be having JS reload the outer page to fetch the flash
It looks like captcha_plug.ex
is trying to redirect the user to the same page with the flash error but for some reason it's just replacing the input form with the redirection target page instead of redirecting the browser. Might want to see if this is unique to Firefox.
The UJS fetchcomplete event for the tags input replaces the entire tag input block with the received HTML page. https://github.com/derpibooru/philomena/blob/5f9e9d98a69cb560e9e10f938ce112399b611294/assets/js/tagsmisc.js#L38-L54
So are you suggesting we check the status code for a 302 and refresh the entire document body with the response if it's a 302 and do what we normally do for a 200?
The server code should render a plain 400, then the client code should reload at top level navigation to fetch the flash.
When a captcha fails, the captcha_plug.ex
does a redirect which returns a 302. We could make it a 400 though.
Yes, that is what I am suggesting.
Fixed in #85
Describe the bug When a user submits a form that requires a captcha (when they're not logged in, for example), failing the captcha will replace the form with the original source page (ends up with page inside a page). See images below.
To Reproduce Steps to reproduce the behavior:
Expected behavior An error message should appear and the input + buttons should not go away.
Screenshots Before submitting
After submitting
Desktop (please complete the following information):