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

Generate renewal token when one is requested #898

Merged
merged 5 commits into from
Jul 24, 2020

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Jul 23, 2020

https://eaflood.atlassian.net/browse/RUBY-1166

If a registration is eligible for renewal NCCC would like us to display the same renewal link that gets included in the renewal reminder emails and letters in registration details.

Currently though we only generate the token used in the link when first generating the reminder email. A registration is eligible for renewal before this is done. And when we first release there will be hundreds that are eligible which will never go through the reminder process because it is too late.

The simplest solution we have for this is to generate it if required. This way we avoid any timing issues or another scheduled task that would have to try and identify all eligible registrations and update them in one go.

So this change will add some logic to automatically generate and save a token if one does not exist when the token is requested.

https://eaflood.atlassian.net/browse/RUBY-1166

If a registration is eligible for renewal NCCC would like us to display the same renewal link that gets included in  the renewal reminder emails and letters in registration details.

Currently though we only generate the token used in the link when first generating the reminder email. A             registration is eligible for renewal before this is done. And when we first release there will be hundreds that are  eligible which will never go through the reminder process because it is too late.

The simplest solution we have for this is to generate it if required. This way we avoid any timing issues or another scheduled task that would have to try and identify all eligible registrations and update them in one go.

So this change will add some logic to automatically generate and save a token if one does not exist when the token is requested.
Kept getting messages about using the wrong version of bundler when trying to run up the rails console in the dummy app.

Spotted that we had a .ruby-version file with the old version in it. I could have corrected the version but actually there is no need for it to be here when we have one in the root of the project.
@Cruikshanks Cruikshanks added the enhancement New feature or request label Jul 23, 2020
@Cruikshanks Cruikshanks self-assigned this Jul 23, 2020
Documentation was scant but found there is a way to override the default getter Mongoid provides.

The key thing is to access the underlying data field you need to use `self[:field_name]`. So now we can just ask for `renew_token` where we need it, and one will be generated automatically if it doesn't exist.
We should no longer need to call this method when we can request `renew_token` directly.
@Cruikshanks Cruikshanks marked this pull request as ready for review July 23, 2020 21:53
Cruikshanks added a commit to DEFRA/waste-carriers-back-office that referenced this pull request Jul 23, 2020
https://eaflood.atlassian.net/browse/RUBY-1166

If a registration is eligible for renewal NCCC would like us to display the same renewal link that gets included in the renewal reminder emails and letters in registration details.

Currently though we only generate the token used in the link when first generating the reminder email. A registration is eligible for renewal before this is done. And when we first release there will be hundreds that are eligible which will never go through the reminder process because it is too late.

The simplest solution we have for this is to generate it if required. We made that change in the engine in [PR #898](DEFRA/waste-carriers-engine#898). This change updates the back-office to use the new functionality.
@Cruikshanks
Copy link
Member Author

Cruikshanks commented Jul 23, 2020

@irisfaraway check out DEFRA/waste-carriers-back-office#962 to see how using this version of the engine affects the back-office 😁

@Cruikshanks
Copy link
Member Author

More for future reference as finding examples of this was super-hard

A subsequent answer recommends using super() instead of self[:renew_token]. It works to get the value in our context, but not to set it. As there seemed to be no issues with the implementation I've stuck a pin in this thought!

@Cruikshanks Cruikshanks merged commit 3c3a6cb into main Jul 24, 2020
@Cruikshanks Cruikshanks deleted the generate-renewal-token-on-request branch July 24, 2020 14:17
Cruikshanks added a commit to DEFRA/waste-carriers-back-office that referenced this pull request Jul 24, 2020
https://eaflood.atlassian.net/browse/RUBY-1166

If a registration is eligible for renewal NCCC would like us to display the same renewal link that gets included in the renewal reminder emails and letters in registration details.

Currently, though we only generate the token used in the link when first generating the reminder email. A registration is eligible for renewal before this is done. And when we first release there will be hundreds that are eligible which will never go through the reminder process because it is too late.

The simplest solution we have for this is to generate it if required. We made that change in the engine in [PR #898](DEFRA/waste-carriers-engine#898). This change updates the back-office to use the new functionality.
Cruikshanks added a commit to DEFRA/waste-carriers-back-office that referenced this pull request Jul 24, 2020
https://eaflood.atlassian.net/browse/RUBY-1166

If a registration is eligible for renewal NCCC would like us to display the same renewal link that gets included in the renewal reminder emails and letters in registration details.

Currently though we only generate the token used in the link when first generating the reminder email. A registration is eligible for renewal before this is done. And when we first release there will be hundreds that are eligible which will never go through the reminder process because it is too late.

The simplest solution we have for this is to generate it if required. We made that change in the engine in [PR #898](DEFRA/waste-carriers-engine#898). This change updates the back-office to use the new functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants