Commit 6d6f61ab authored by Elliot Ward's avatar Elliot Ward
Browse files

Issue #3249158: 🏷️ Add additional token for URL encoded email address.

parent 86308fee
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ function rest_password_mail_tokens(array &$replacements, array $data, array $opt
    $replacements['[user:rest-temp-password]'] = rest_password_temp_pass_token($data['user'], $options);
    $replacements['[user:name-url-encode]'] = rest_password_fix_name_url_encode($data['user'], $options);
    $replacements['[user:name-url-encode-spaces]'] = rest_password_fix_name_url_encode_sapace($data['user'], $options);
    $replacements['[user:mail-url-encode]'] = rest_password_fix_mail_url_encode($data['user']);
  }
}

@@ -196,6 +197,19 @@ function rest_password_fix_name_url_encode_sapace(UserInterface $account, array
  return str_replace(' ', '%20', $name);
}

/**
 * Token call back for [user:mail-url-encode].
 *
 * @param \Drupal\user\UserInterface $account
 *   An object containing the user account.
 *
 * @return string
 *   The url encoded version of the account's email address.
 */
function rest_password_fix_mail_url_encode(UserInterface $account) {
  return urlencode($account->getEmail());
}

/**
 * Acts like user mail tokens.
 *