Drupal 7에서는 코드를 통해 사용자 # 1 비밀번호를 재설정 할 수 있음을 알고 있습니다.
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()Drupal 8에는 더 이상 존재하지 않습니다.)
또는 다음 코드를 사용할 수 있습니다.
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);
Drupal 8과 동등한 코드는 무엇입니까? 이 목적으로 어떤 API를 사용해야합니까?