Wiem, że w Drupal 7 mogłem zresetować hasło użytkownika nr 1 za pomocą kodu.
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once DRUPAL_ROOT . '/includes/password.inc';
$newhash = user_hash_password('newpass');
$updatepass = db_update('users')
->fields(array('pass' => $newhash))
->condition('uid', '1', '=')
->execute();
( user_hash_password()już nie istnieje w Drupal 8)
Alternatywnie mógłbym użyć następującego kodu.
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once DRUPAL_ROOT . '/includes/password.inc';
$edit['pass'] = 'newpass';
$account= user_load(1);
user_save($account, $edit);
Jaki jest równoważny kod dla Drupal 8? Jakiego interfejsu API powinienem użyć do tego celu?