Migration from drupal 6 to 7 keeping user password same

Migration from drupal 6 to 7 keeping user password same

This is a quick Hack to enable users to login with existing password after migration of users Drupal 6 to Drupal 7

The following code can be used.
A better way would be to create a custom module and Call this function in that module so that no changes are done to core files.

In user.module file .. 
function user_authenticate($name, $password) {
  $uid = FALSE;
  if (!empty($name) && !empty($password)) {
    $account = user_load_by_name($name);
    if ($account) {
      // Allow alternate password hashing schemes.
      require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
      if (user_check_password($password, $account)) {
        // Successful authentication.
        $uid = $account->uid;

        // Update user to new password scheme if needed.
        if (user_needs_new_hash($account)) {
          user_save($account, array('pass' => $password));
        }
      }
      // -----Add this Code After Migration from Drupal 6 to Drupal 7 to allow users to login with same password
      else if($account->pass == md5($password)){ //Check For Drupal 6
          // Successful authentication.
        $uid = $account->uid;

        // Update user to new password scheme.
          user_save($account, array('pass' => $password));
      }
      // -----Add this Code After Migration from Drupal 6 to Drupal 7 to allow users to login with same password
    }
  }
  return $uid;
}

You can also use the following Sandbox project module will give access to users using the old password.
https://www.drupal.org/project/password_6_7
Do submit reviews.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
  • Lazy-loading is enabled for both <img> and <iframe> tags. If you want certain elements skip lazy-loading, add no-b-lazy class name.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.