[openstreetmap/openstreetmap-website] Draft: Refactor confirmations controller (PR #5895)

rkoeze notifications at github.com
Sat Apr 5 17:43:56 UTC 2025


<!--
Please read the contributing guidelines before making a PR:
  https://github.com/openstreetmap/openstreetmap-website/blob/master/CONTRIBUTING.md

Pay particular attention to the section on how to present PRs:
  https://github.com/openstreetmap/openstreetmap-website/blob/master/CONTRIBUTING.md#pull-requests
-->

### Description
Draft PR for a restful refactor of the confirmations controller. The original intention here was for a purely structural set of changes that otherwise preserved existing functionality. However, moving toward a more restful structure prompted reusing the `#show` endpoint for both confirmation scenarios, which in turn introduced a few changes in behavior. 

I am looking for some initial feedback that this is going in an acceptable direction. I am of course happy to break this out into smaller PRs. 

Changes:
- Introduce restful routes for confirmations controller
- Deprecate `new_user` and `new_email` tokens in favor of single `account_confirmation` token
- Some UI changes around confirmation and error messages

Remaining work:
- [ ] Fix failing tests
- [ ] Add more test coverage

### How has this been tested?
I've gone through both of the new account and email change confirmation flows locally. I've also tested out the scenarios where confirmation emails are sent out with the currently deployed token generation logic but are handled by the code in this PR.

You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/5895

-- Commit Summary --

  * Move controller methods to user model
  * Add restful routes
  * Make controller restful
  * Update route invocations
  * Centralize token usage
  * Update views
  * Update abilities
  * Update strings
  * Get tests passing
  * Fix a couple of bugs

-- File Changes --

    M app/abilities/ability.rb (2)
    M app/controllers/concerns/session_methods.rb (2)
    M app/controllers/concerns/user_methods.rb (4)
    M app/controllers/confirmations_controller.rb (111)
    M app/controllers/users_controller.rb (4)
    M app/mailers/user_mailer.rb (10)
    M app/models/user.rb (55)
    D app/views/confirmations/confirm.html.erb (36)
    D app/views/confirmations/confirm_email.html.erb (16)
    A app/views/confirmations/new.html.erb (20)
    M config/locales/en.yml (16)
    M config/routes.rb (13)
    M test/controllers/confirmations_controller_test.rb (152)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/5895.patch
https://github.com/openstreetmap/openstreetmap-website/pull/5895.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5895
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5895 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250405/da349ad3/attachment.htm>


More information about the rails-dev mailing list