? sites/d6.local
? sites/all/modules
Index: modules/openid/openid.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.module,v
retrieving revision 1.19.2.9
diff -u -p -r1.19.2.9 openid.module
--- modules/openid/openid.module	7 Dec 2009 12:52:22 -0000	1.19.2.9
+++ modules/openid/openid.module	4 Aug 2010 00:45:54 -0000
@@ -111,7 +111,7 @@ function openid_form_alter(&$form, $form
       '#weight' => -1,
       '#description' => l(t('What is OpenID?'), 'http://openid.net/', array('external' => TRUE)),
     );
-    $form['openid.return_to'] = array('#type' => 'hidden', '#value' => url('openid/authenticate', array('absolute' => TRUE, 'query' => drupal_get_destination())));
+    $form['openid.return_to'] = array('#type' => 'hidden', '#value' => url('openid/authenticate', array('absolute' => TRUE, 'query' => user_login_destination())));
   }
   elseif ($form_id == 'user_register' && isset($_SESSION['openid']['values'])) {
     // We were unable to auto-register a new user. Prefill the registration
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.892.2.25
diff -u -p -r1.892.2.25 user.module
--- modules/user/user.module	2 Jun 2010 12:47:58 -0000	1.892.2.25
+++ modules/user/user.module	4 Aug 2010 00:45:54 -0000
@@ -2527,3 +2527,18 @@ function _user_forms(&$edit, $account, $
 
   return empty($groups) ? FALSE : $groups;
 }
+
+/**
+ * Prepare a destination query string for use in combination with drupal_goto().
+ *
+ * Used to direct the user back to the referring page after completing
+ * the openid login.  This function prevents the login page from being
+ * returned because that page will give an access denied message to an
+ * authenticated user.
+ *
+ * @see drupal_get_destination()
+ */
+function user_login_destination() {
+  $destination = drupal_get_destination();
+  return $destination == 'destination=user%2Flogin' ? 'destination=user' : $destination;
+}
