diff --git a/modules/user/user.module b/modules/user/user.module
index 625a00c..4c4706e 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -162,14 +162,14 @@ function user_load($user_info = array()) {
     return FALSE;
   }
 
+  $password_check_needed = FALSE;
   foreach ($user_info as $key => $value) {
     if ($key == 'uid' || $key == 'status') {
       $query[] = "$key = %d";
       $params[] = $value;
     }
     else if ($key == 'pass') {
-      $query[] = "pass = '%s'";
-      $params[] = md5($value);
+      $password_check_needed = TRUE;
     }
     else {
       $query[]= "LOWER($key) = LOWER('%s')";
@@ -181,6 +181,13 @@ function user_load($user_info = array()) {
   if ($user = db_fetch_object($result)) {
     $user = drupal_unpack($user);
 
+    if ($password_check_needed) {
+      module_load_include('inc', 'phpass', 'password');
+      if (!user_check_password($user_info['pass'], $user)) {
+        return FALSE;
+      }
+    }
+
     $user->roles = array();
     if ($user->uid) {
       $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
