Skip to content
Snippets Groups Projects
Commit 02e52fc9 authored by Adam G-H's avatar Adam G-H
Browse files

Fix password bug

parent 78ca82f5
No related branches found
No related tags found
1 merge request!262Use key-value to store the password temporarily
Pipeline #358384 failed
......@@ -4,11 +4,12 @@ declare(strict_types=1);
use Composer\InstalledVersions;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Render\Element\Password;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Recipe\RecipeRunner;
use Drupal\drupal_cms_installer\Form\AccountForm;
use Drupal\drupal_cms_installer\Form\RecipesForm;
use Drupal\drupal_cms_installer\Form\SiteNameForm;
use Drupal\drupal_cms_installer\MessageInterceptor;
......@@ -133,7 +134,9 @@ function drupal_cms_installer_form_install_settings_form_alter(array &$form): vo
*
* @see \Drupal\Core\Installer\Form\SiteConfigureForm
*/
function drupal_cms_installer_form_install_configure_form_alter(array &$form): void {
function drupal_cms_installer_form_install_configure_form_alter(array &$form, FormStateInterface $form_state): void {
global $install_state;
$form['#title'] = t('Create your account');
$form['step'] = [
'#prefix' => '<p class="cms-installer__step">',
......@@ -184,6 +187,7 @@ function drupal_cms_installer_form_install_configure_form_alter(array &$form): v
'#required' => TRUE,
'#default_value' => $install_state['forms']['install_configure_form']['account']['pass']['pass1'] ?? '',
'#weight' => 20,
'#value_callback' => '_drupal_cms_installer_password_value',
];
// Hide parts of the form we don't care about.
......@@ -193,6 +197,15 @@ function drupal_cms_installer_form_install_configure_form_alter(array &$form): v
$form['actions']['submit']['#value'] = t('Finish');
}
function _drupal_cms_installer_password_value(&$element, $input, FormStateInterface $form_state): mixed {
// Work around this fact that Drush and `drupal install`, which submit this
// form programmatically, assume the password is a password_confirm element.
if (is_array($input) && $form_state->isProgrammed()) {
$input = $input['pass1'];
}
return Password::valueCallback($element, $input, $form_state);
}
/**
* Runs a batch job that applies the template and add-on recipes.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment