diff --git a/core/modules/user/src/RegisterForm.php b/core/modules/user/src/RegisterForm.php
index d24a4b4..a44304d 100644
--- a/core/modules/user/src/RegisterForm.php
+++ b/core/modules/user/src/RegisterForm.php
@@ -91,6 +91,9 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
     $form_state->setValue('init', $form_state->getValue('mail'));
 
     parent::submitForm($form, $form_state);
+
+    // Remove the plain text password from the form state.
+    $form_state->unsetValue('pass');
   }
 
   /**
@@ -98,7 +101,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
    */
   public function save(array $form, FormStateInterface $form_state) {
     $account = $this->entity;
-    $pass = $account->getPassword();
     $admin = $form_state->getValue('administer_users');
     $notify = !$form_state->isValueEmpty('notify');
 
@@ -111,9 +113,6 @@ public function save(array $form, FormStateInterface $form_state) {
 
     $this->logger('user')->notice('New user: %name %email.', array('%name' => $form_state->getValue('name'), '%email' => '<' . $form_state->getValue('mail') . '>', 'type' => $account->link($this->t('Edit'), 'edit-form')));
 
-    // Add plain text password into user account to generate mail tokens.
-    $account->password = $pass;
-
     // New administrative account without notification.
     if ($admin && !$notify) {
       drupal_set_message($this->t('Created a new user account for <a href=":url">%name</a>. No email has been sent.', array(':url' => $account->url(), '%name' => $account->getUsername())));
