Skip to main content
improved spelling and punctuation
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Migrate user password hash from md5 to Drupal standard (phpass)

We are migrationgmigrating our old site from core phpplain PHP to drupalDrupal 8. Passwords are encryptedhashed with md5MD5 in the old site and wantsite; I need to migrate them as SHA algorithmin Drupal.

I tried belowthe following code, but thisit takes md5the password as simpleplain text password and convert them ascalculates its SHA hash.

public function prepareRow(Row $row) {
    $password = $row->getSourceProperty('user_password');
    $hash = \Drupal::service('password')->hash($password);
    $row->setSourceProperty('user_password', $hash);
  }

This is my configthe configuration file:.

id: users
label: User migration
migration_group: mymodule_general_migration_groups
source:
  plugin: mymodule_migration_users
process:
  pass: user_password
  mail: user_email
  init: user_email
  status:
    plugin: default_value
    default_value: 1
  name:
    plugin: dedupe_entity
    source: username
    entity_type: user
    field: name
    postfix: _
  created:
    plugin: callback
    source: created
    callable: strtotime
  changed: user_regdate
  access: user_regdate
  login: user_lastvisit
destination:
  plugin: entity:user
  md5_password: true
migration_dependencies: {}
dependencies:
  enforced:
    module:
      - mymodule_migration

Migrate user password hash from md5 to Drupal standard (phpass)

We are migrationg our old site from core php to drupal 8. Passwords are encrypted with md5 in old site and want to migrate them as SHA algorithm

I tried below code but this takes md5 as simple text password and convert them as SHA

public function prepareRow(Row $row) {
    $password = $row->getSourceProperty('user_password');
    $hash = \Drupal::service('password')->hash($password);
    $row->setSourceProperty('user_password', $hash);
  }

This is my config file:

id: users
label: User migration
migration_group: mymodule_general_migration_groups
source:
  plugin: mymodule_migration_users
process:
  pass: user_password
  mail: user_email
  init: user_email
  status:
    plugin: default_value
    default_value: 1
  name:
    plugin: dedupe_entity
    source: username
    entity_type: user
    field: name
    postfix: _
  created:
    plugin: callback
    source: created
    callable: strtotime
  changed: user_regdate
  access: user_regdate
  login: user_lastvisit
destination:
  plugin: entity:user
  md5_password: true
migration_dependencies: {}
dependencies:
  enforced:
    module:
      - mymodule_migration

Migrate user password hash

We are migrating our old site from plain PHP to Drupal 8. Passwords are hashed with MD5 in the old site; I need to migrate them in Drupal.

I tried the following code, but it takes the password as plain text and calculates its SHA hash.

public function prepareRow(Row $row) {
    $password = $row->getSourceProperty('user_password');
    $hash = \Drupal::service('password')->hash($password);
    $row->setSourceProperty('user_password', $hash);
  }

This is the configuration file.

id: users
label: User migration
migration_group: mymodule_general_migration_groups
source:
  plugin: mymodule_migration_users
process:
  pass: user_password
  mail: user_email
  init: user_email
  status:
    plugin: default_value
    default_value: 1
  name:
    plugin: dedupe_entity
    source: username
    entity_type: user
    field: name
    postfix: _
  created:
    plugin: callback
    source: created
    callable: strtotime
  changed: user_regdate
  access: user_regdate
  login: user_lastvisit
destination:
  plugin: entity:user
  md5_password: true
migration_dependencies: {}
dependencies:
  enforced:
    module:
      - mymodule_migration

User Migrate user password migrationhash from md5 to hashDrupal standard (phpass)

added 849 characters in body
Source Link

We are migrationg our old site from core php to drupal 8. Passwords are encrypted with md5 in old site and want to migrate them as SHA algorithm

I tried below code but this takes md5 as simple text password and convert them as SHA

public function prepareRow(Row $row) {
    $password = $row->getSourceProperty('user_password');
    $hash = \Drupal::service('password')->hash($password);
    $row->setSourceProperty('user_password', $hash);
  }

This is my config file:

id: users
label: User migration
migration_group: mymodule_general_migration_groups
source:
  plugin: mymodule_migration_users
process:
  pass: user_password
  mail: user_email
  init: user_email
  status:
    plugin: default_value
    default_value: 1
  name:
    plugin: dedupe_entity
    source: username
    entity_type: user
    field: name
    postfix: _
  created:
    plugin: callback
    source: created
    callable: strtotime
  changed: user_regdate
  access: user_regdate
  login: user_lastvisit
destination:
  plugin: entity:user
  md5_password: true
migration_dependencies: {}
dependencies:
  enforced:
    module:
      - mymodule_migration

We are migrationg our old site from core php to drupal 8. Passwords are encrypted with md5 in old site and want to migrate them as SHA algorithm

I tried below code but this takes md5 as simple text password and convert them as SHA

public function prepareRow(Row $row) {
    $password = $row->getSourceProperty('user_password');
    $hash = \Drupal::service('password')->hash($password);
    $row->setSourceProperty('user_password', $hash);
  }

We are migrationg our old site from core php to drupal 8. Passwords are encrypted with md5 in old site and want to migrate them as SHA algorithm

I tried below code but this takes md5 as simple text password and convert them as SHA

public function prepareRow(Row $row) {
    $password = $row->getSourceProperty('user_password');
    $hash = \Drupal::service('password')->hash($password);
    $row->setSourceProperty('user_password', $hash);
  }

This is my config file:

id: users
label: User migration
migration_group: mymodule_general_migration_groups
source:
  plugin: mymodule_migration_users
process:
  pass: user_password
  mail: user_email
  init: user_email
  status:
    plugin: default_value
    default_value: 1
  name:
    plugin: dedupe_entity
    source: username
    entity_type: user
    field: name
    postfix: _
  created:
    plugin: callback
    source: created
    callable: strtotime
  changed: user_regdate
  access: user_regdate
  login: user_lastvisit
destination:
  plugin: entity:user
  md5_password: true
migration_dependencies: {}
dependencies:
  enforced:
    module:
      - mymodule_migration
Source Link
Loading