Migration from drupal 6 to 7 keeping user password same
After users' migration from Drupal 6 to Drupal 7, this fast hack enables users to login using their existing passwords.
You can use the code listed below.
To avoid changing core files, it would be preferable to construct a custom module and use this function from within that module.
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