Index: modules/logintoboggan/logintoboggan.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/logintoboggan/logintoboggan.module,v
retrieving revision 1.7.2.56
diff -u -r1.7.2.56 logintoboggan.module
--- modules/logintoboggan/logintoboggan.module	1 Nov 2006 02:08:07 -0000	1.7.2.56
+++ modules/logintoboggan/logintoboggan.module	17 Dec 2006 12:35:01 -0000
@@ -367,14 +367,29 @@
 
   global $user;
 
-  // If it's not an anonymous user, and the user has the pre-auth role, and the pre-auth role
-  // isn't also the auth role, then unset the auth role for this user--they haven't validated yet.
+  // Make sure any user with pre-auth role doesn't have authenticated user role
+  _logintoboggan_user_roles_alter($user);
+}
+
+/**
+ * Alter user roles for loaded user account.
+ *
+ * If user is not an anonymous user, and the user has the pre-auth role, and the pre-auth role
+ * isn't also the auth role, then unset the auth role for this user--they haven't validated yet.
+ *
+ * This alteration is required because sess_read() and user_load() automatically set the
+ * authenticated user role for all non-anonymous users (see http://drupal.org/node/92361).
+ *
+ * @param &$account
+ *    User account to have roles adjusted.
+ */
+function _logintoboggan_user_roles_alter(&$account) {
   $id = logintoboggan_validating_id();
-  $in_pre_auth_role = in_array($id, array_keys($user->roles));
-  if ($user->uid && $in_pre_auth_role) {
-    $user->status = 1;
-    if ($id != 2) {
-      unset($user->roles[2]);
+  $in_pre_auth_role = in_array($id, array_keys($account->roles));
+  if ($account->uid && $in_pre_auth_role) {
+    $account->status = 1;
+    if ($id != DRUPAL_AUTHENTICATED_RID) {
+      unset($account->roles[DRUPAL_AUTHENTICATED_RID]);
     }
   }
 }
@@ -865,6 +881,11 @@
   } elseif ($op == 'login' && variable_get('login_successful', 0)) {
     drupal_set_message(t('Login successful.'));
   }
+  elseif ($op == 'load') {
+    // Just loaded the user into $user_edit.
+    // If the user has the pre-auth role, unset the authenticated role
+    _logintoboggan_user_roles_alter($user_edit);
+  }
 }
 
 /**
