Problem/Motivation
To enable easier contribution, I am splitting this issue into smaller ones. I have created a new minor dev release, 1.1.x-dev for developing this feature, as it will need several MRs to complete.
Currently the login link is appended to the bottom of the verification email. This is means that nothing can be below it in the email.
This was always intended to be a stop-gap measure to get the basics of the module working.
It makes sense to use the Drupal token system to fill in the log in link. This could also allow other tokens to be included.
Steps to reproduce
Use module to send login link and note it's always at the bottom of the email.
Proposed resolution
Use Drupal's Token replacement to provide a new token [verify-email:url].
Remaining tasks
- Add a new Hooks class in
src/Hook/VerifyEmailTokensHooks. - Add a
tokenInfomethod, with theHook('token_info')attribute. This method should return a nested array containing "types" and "tokens". Types should contain an array of one element for "verify-email", and must specify the "needs-data" element. Tokens should also be an array specifying the "verify-email" type, and the "url" token within it. - Add a
tokensmethod, withHook('tokens')attribute. This should check for 'type' of 'verify-email' and presence of 'verify-email' in data, and if present, check for 'url' in the tokens array. If present, it should return a replacement array containing the URL from the data array. - Add an entry to
services.yamlfor the new class. I don't think it will require any dependencies injected. - Add
[legacyHook]attributes and functions fortokenInfoandtokens. - In the
src/Service/Verifierclass, add theDrupal\Core\Utility\Tokenclass to the constructor, and add the@tokenservice inservices.yaml. - In
Verifier::sendVerficiationEmail, create adataarray, and place the generated link in it. Pass the subject and body of the email message through thereplace()function of the Token service. This should replace the current appended link. - In
src/Form/VerifyEmailAddEditForm, add#descriptionto the 'email_body' field, containing help text about the[verify-email:url]token. - Add an update hook to append the
[verify-email:url]to the email message for each Verify Email config entity. - It would also be good to add test coverage. I think a unit or kernel test that calls the replace function and verifies that the url token gets replaced correctly should suffice.
User interface changes
The only UI change is the addition of description to the email body field.
API changes
None.
Data model changes
None.
Comments
Comment #2
lostcarpark commentedComment #3
lavanyatalwar commentedAdded the service definition in #3526674.
Please review.
Comment #4
lostcarpark commentedThank you, @lavanyatalwar!
Just for future reference, when you complete work on an issue, you should update the status to "needs review". Otherwise, it can be easy for reviewers to overlook it. I'm updating the status for you now, and will review shortly.
Comment #5
lostcarpark commentedOh wait, apologies, I didn't notice the comment was on the parent issue. Setting back to active.
Comment #6
lostcarpark commentedMarking issue complete as all child tasks closed.
Comment #7
lostcarpark commented