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

Redirect to confirmation message after POST when making report #4362

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

davea
Copy link
Member

@davea davea commented Mar 30, 2023

@codecov
Copy link

codecov bot commented Mar 30, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (085d1c2) 82.72% compared to head (fefada8) 80.36%.

❗ Current head fefada8 differs from pull request most recent head f104a16. Consider uploading reports for the commit f104a16 to get more accurate results

Files Patch % Lines
perllib/FixMyStreet/App/Controller/Report.pm 90.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4362      +/-   ##
==========================================
- Coverage   82.72%   80.36%   -2.36%     
==========================================
  Files         385      374      -11     
  Lines       30039    30113      +74     
  Branches     4732     4889     +157     
==========================================
- Hits        24849    24200     -649     
- Misses       3756     4473     +717     
- Partials     1434     1440       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dracos dracos force-pushed the master branch 2 times, most recently from 035a6aa to 02db8ea Compare April 5, 2023 11:05
@davea davea force-pushed the redirect-after-report-creation branch 2 times, most recently from b3f80bf to b76c875 Compare May 4, 2023 19:40
@dracos dracos force-pushed the master branch 2 times, most recently from b96bd67 to e8ccb20 Compare May 12, 2023 11:33
@davea davea force-pushed the redirect-after-report-creation branch 2 times, most recently from e25d811 to bc6249b Compare June 26, 2023 10:57
@davea davea force-pushed the redirect-after-report-creation branch 2 times, most recently from 5c4c325 to 4f2d265 Compare July 5, 2023 08:10
@dracos dracos force-pushed the master branch 2 times, most recently from 604a72c to 8abd0a9 Compare July 14, 2023 11:56
@dracos dracos force-pushed the master branch 3 times, most recently from 11e15b2 to 8becd5f Compare September 21, 2023 13:59
@davea davea force-pushed the redirect-after-report-creation branch 5 times, most recently from 096193e to 750133c Compare October 23, 2023 11:55
@davea davea changed the title WIP redirect to confirmation message after POST when making report Redirect to confirmation message after POST when making report Oct 23, 2023
@davea davea marked this pull request as ready for review October 23, 2023 12:10
@davea davea requested a review from dracos October 23, 2023 12:10
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, and I can see you've tried to deal with the non_public/unconfirmed issues, but I don't think this is going to work like this due to the leakage (actual and potential) of information. How about this, would this work - redirect to a /report/new/confirmation?token=[token] or /report/new/confirmation/[token] or whatever endpoint where token is generated as, I dunno, hmac_sha1_hex("$time-$id", secret); Then that endpoint will validate that hash and allow fetching of that report ID alone for 1 minute/30s since $time (similar to how Auth.pm does this for the CSRF token). And that can then show either template, wouldn't need to worry about state/non_public/etc, as it knows it's the report just created.

templates/web/base/tokens/confirm_problem.html Outdated Show resolved Hide resolved
perllib/FixMyStreet/App/Controller/Report.pm Show resolved Hide resolved
perllib/FixMyStreet/App/Controller/Report.pm Show resolved Hide resolved
perllib/FixMyStreet/App/Controller/Report.pm Outdated Show resolved Hide resolved
@davea davea force-pushed the redirect-after-report-creation branch from 750133c to 3816a3f Compare January 31, 2024 08:42
@davea
Copy link
Member Author

davea commented Jan 31, 2024

Thanks for the suggestion of the token - that's made it much neater! I don't think any/all of the template changes are needed any more but the tests aren't happy if I just back them all out, so once I've got that sorted it'll be ready for another review.

@davea davea force-pushed the redirect-after-report-creation branch from 3816a3f to e27b7d2 Compare January 31, 2024 11:34
@davea davea force-pushed the redirect-after-report-creation branch from e27b7d2 to c66aa3a Compare January 31, 2024 12:58
@davea davea requested a review from dracos January 31, 2024 12:59
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, looks good, just some possible refactoring suggestions for perfection ;)

perllib/FixMyStreet/App/Controller/Report.pm Outdated Show resolved Hide resolved
perllib/FixMyStreet/App/Controller/Report.pm Outdated Show resolved Hide resolved
perllib/FixMyStreet/App/Controller/Report.pm Show resolved Hide resolved
perllib/FixMyStreet/App/Controller/Report.pm Outdated Show resolved Hide resolved
perllib/FixMyStreet/App/Controller/Report/New.pm Outdated Show resolved Hide resolved
@davea davea requested a review from dracos February 1, 2024 19:06
@dracos dracos force-pushed the redirect-after-report-creation branch from 35c0a41 to b97f12e Compare February 2, 2024 07:11
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not spotting the test failure before, but hopefully have diagnosed it

perllib/FixMyStreet/App/Controller/Report.pm Outdated Show resolved Hide resolved
@davea davea requested a review from dracos February 2, 2024 14:42
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly the same tests are still failing (only on coverage, so I still think it must be this part somehow? but your fix looks good. And in e.g. report_new.t surely it can't be taking a minute to create the report? But what else could it be) :-/ Guess we might need more debugging into if it's reaching that if statement, what URL it's constructed at that point, might have to push a yucky print STDERR "$cutoff $timestamp\n"; and things like that, I can't get it to happen locally at all.

@davea
Copy link
Member Author

davea commented Feb 5, 2024

Looks like it was indeed just taking a long time...! I increased the token cutoff to 3 minutes and the coverage tests all passed that time.

@davea davea force-pushed the redirect-after-report-creation branch from fefada8 to f104a16 Compare February 5, 2024 13:57
@davea
Copy link
Member Author

davea commented Feb 5, 2024

Phew, OK, think we're there now...

@davea davea requested a review from dracos February 5, 2024 14:16
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all that :)

@davea davea merged commit f104a16 into master Feb 5, 2024
20 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