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

  1. Add a new Hooks class in src/Hook/VerifyEmailTokensHooks.
  2. Add a tokenInfo method, with the Hook('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.
  3. Add a tokens method, with Hook('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.
  4. Add an entry to services.yaml for the new class. I don't think it will require any dependencies injected.
  5. Add [legacyHook] attributes and functions for tokenInfo and tokens.
  6. In the src/Service/Verifier class, add the Drupal\Core\Utility\Token class to the constructor, and add the @token service in services.yaml.
  7. In Verifier::sendVerficiationEmail, create a data array, and place the generated link in it. Pass the subject and body of the email message through the replace() function of the Token service. This should replace the current appended link.
  8. In src/Form/VerifyEmailAddEditForm, add #description to the 'email_body' field, containing help text about the [verify-email:url] token.
  9. Add an update hook to append the [verify-email:url] to the email message for each Verify Email config entity.
  10. 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

lostcarpark created an issue. See original summary.

lostcarpark’s picture

Title: Add token support and provide token for login link » [Meta] Add token support and provide token for login link
Version: 1.0.x-dev » 1.1.x-dev
Assigned: Unassigned » lostcarpark
Issue summary: View changes
lavanyatalwar’s picture

Added the service definition in #3526674.
Please review.

lostcarpark’s picture

Status: Active » Needs review

Thank 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.

lostcarpark’s picture

Status: Needs review » Active

Oh wait, apologies, I didn't notice the comment was on the parent issue. Setting back to active.

lostcarpark’s picture

Marking issue complete as all child tasks closed.

lostcarpark’s picture

Status: Active » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.