Skip to content
Snippets Groups Projects

Resolve #85494 "Use email verification 9.3.x"

5 unresolved threads

Rebase off 9.3.x Added test per comment #279.6 Addressed feedback from MR 437 except disputed comments

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
457 }
458 }
459
460 /**
461 * Send notifications after the account is updated.
462 * This callback is called after ::submitForm and ::save complete, so that the user
463 * entity is guaranteed to be fully updated with any new password hashes.
464 * This ensures that notifications that contain any URLs using user_pass_rehash are
465 * valid and are able to use the hashed password that is generated upon save only.
466 *
467 * @param array $form
468 * An associative array containing the structure of the form.
469 * @param \Drupal\Core\Form\FormStateInterface $form_state
470 * The current state of the form.
471 */
472 public function notify(array &$form, FormStateInterface $form_state) {
  • Comment on lines +461 to +472

    This piece of code does much more than notify. The call to mail_change_verification and setting the email address back to the original are a key part of this logic. I think this needs a different name to indicate what it's doing.

  • Please register or sign in to reply
  • 469 * @param \Drupal\Core\Form\FormStateInterface $form_state
    470 * The current state of the form.
    471 */
    472 public function notify(array &$form, FormStateInterface $form_state) {
    473 $new_mail = $form_state->get('mail_change_verification');
    474 if ($new_mail !== NULL) {
    475 // Send a verification to the new email address.
    476 /** @var \Drupal\user\UserInterface $account */
    477 $account = $this->getEntity();
    478 /** @var \Drupal\user\UserInterface $account_cloned */
    479 $account_cloned = clone $account;
    480 $account_cloned->setEmail($new_mail);
    481 if (_user_mail_notify('mail_change_verification', $account_cloned) !== NULL) {
    482 // Send notification email to the old email address, if it's set.
    483 if ($account->getEmail()) {
    484 _user_mail_notify('mail_change_notification', $account);
  • 475 // Send a verification to the new email address.
    476 /** @var \Drupal\user\UserInterface $account */
    477 $account = $this->getEntity();
    478 /** @var \Drupal\user\UserInterface $account_cloned */
    479 $account_cloned = clone $account;
    480 $account_cloned->setEmail($new_mail);
    481 if (_user_mail_notify('mail_change_verification', $account_cloned) !== NULL) {
    482 // Send notification email to the old email address, if it's set.
    483 if ($account->getEmail()) {
    484 _user_mail_notify('mail_change_notification', $account);
    485 }
    486 $this->messenger()->addWarning($this->t('You must confirm your email address. Further instructions have been sent to your new email address.'));
    487 } else {
    488 // Process change immediately if no verification email is configured.
    489 $account->setEmail($new_mail);
    490 $account->save();
  • 466 *
    467 * @param array $form
    468 * An associative array containing the structure of the form.
    469 * @param \Drupal\Core\Form\FormStateInterface $form_state
    470 * The current state of the form.
    471 */
    472 public function notify(array &$form, FormStateInterface $form_state) {
    473 $new_mail = $form_state->get('mail_change_verification');
    474 if ($new_mail !== NULL) {
    475 // Send a verification to the new email address.
    476 /** @var \Drupal\user\UserInterface $account */
    477 $account = $this->getEntity();
    478 /** @var \Drupal\user\UserInterface $account_cloned */
    479 $account_cloned = clone $account;
    480 $account_cloned->setEmail($new_mail);
    481 if (_user_mail_notify('mail_change_verification', $account_cloned) !== NULL) {
    • This email send should only happen happen if:

      1. The account is not new
      2. The user is not an admin
      3. Email verification is turned on
      4. The email address actually changed (might cover case #1)
    • Please register or sign in to reply
  • 426 435 * {@inheritdoc}
    427 436 */
    428 437 public function submitForm(array &$form, FormStateInterface $form_state) {
    438 /** @var \Drupal\user\UserInterface $account */
    439 $account = $this->getEntity();
    440 $new_mail = $form_state->getValue('mail');
    441 $old_mail = $account->getEmail();
    442
    443 $own_account = $this->currentUser()->id() === $account->id();
  • Pieter Frenssen added 611 commits

    added 611 commits

    • 2138aaff...4bb9f46b - 610 commits from branch project:9.3.x
    • ae92d305 - Merge remote-tracking branch 'origin/9.3.x' into 85494-use-email-verification-9.3.x

    Compare with previous version

  • Lee Rowlands changed target branch from 9.3.x to 9.4.x

    changed target branch from 9.3.x to 9.4.x

  • Please register or sign in to reply
    Loading