diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index 080f0bf3f9..7666eecd68 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -126,6 +126,10 @@ public function form(array $form, FormStateInterface $form_state) { // The user must enter their current password to change to a new one. if ($user->id() == $account->id()) { + // On one-time reset password form set the password field required + // otherwise leave not required. This will fix empty password on reset. + $form['account']['pass']['#required'] = $form_state->get('user_pass_reset'); + $form['account']['current_pass'] = [ '#type' => 'password', '#title' => $this->t('Current password'),