Properly replace token [user:one-time-login-url] to avoid issues with config translations

Created on 4 April 2024, 3 months ago
Updated 9 May 2024, about 2 months ago

Problem/Motivation

When a user signup on the platform from a course (e.g. by requesting to join a course), a destination URL is appended to the one-time-login link sent in the email. It's currently done in \Drupal\social_course\SocialCourseOverrides by overriding the config user.mail and replacing the [user:one-time-login-url] string by [user:one-time-login-url][user:destination-url], which contains the destination URL.

However, since the original config value is being assigned directly to the mail body, the messages are always sent in the original language, even though there is a config translation available.

Proposed resolution

Since overriding a configuration is not always a good idea, given that it makes hard to maintain and debug, the proposed solution is to properly replace the token [user:one-time-login-url] in a hook_mail_alter(), so it will always return the proper content according to the user's language.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Fixed

Version

5.2

Component

Code

Created by

πŸ‡§πŸ‡·Brazil tregismoreira

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024