Index: fb_connect.module
===================================================================
--- fb_connect.module	(revision 2124)
+++ fb_connect.module	(working copy)
@@ -573,6 +573,10 @@
       variable_set('fb_connect_primary_apikey', $node->fb_app['apikey']);
       drupal_set_message(t('!node is now the primary Facebook Connect application.', array('!node' => l($node->title, 'node/' . $node->nid))));
     }
+    else if ($node->fb_app['apikey'] == variable_get('fb_connect_primary_apikey')) {
+      // This app was the primary one, but the user has unchecked it.
+      variable_set('fb_connect_primary_apikey', NULL);
+    }
   }
 }
 
Index: fb_devel.module
===================================================================
--- fb_devel.module	(revision 2124)
+++ fb_devel.module	(working copy)
@@ -126,6 +126,17 @@
       }
       watchdog('fb_devel', $message, array(), WATCHDOG_ERROR);
     }
+
+    // Require login sanity check.
+    $fb_app_data = fb_app_get_data($fb_app);
+    if (isset($fb_app_data['fb_user']) && $fb_app_data['fb_user']['require_login'] == FB_USER_OPTION_REQUIRE_LOGIN) {
+      $message = 'Drupal for Facebook options for require login have changed.  You must manually <a href=!url>edit your application</a>.  Look for the require login options under canvas page options.  No longer under user options.';
+      $args = array('!url' => url('node/' . $fb_app->nid . '/edit'));
+      if (user_access('access administration pages')) {
+        drupal_set_message(t($message, $args), 'error');
+      }
+      watchdog('fb_devel', $message, $args, WATCHDOG_ERROR);      
+    }
   }
   
   else if ($op == FB_APP_OP_EVENT) {
Index: fb_canvas.module
===================================================================
--- fb_canvas.module	(revision 2124)
+++ fb_canvas.module	(working copy)
@@ -2,12 +2,18 @@
 /**
  * @file
  * 
- * This module provides some app-specific navigation to facebook apps.  This
- * is fairly experimental material.  May change a lot in near future.
+ * This module provides support for Canvas page applications.  Use
+ * Drupal to power traditional Facebook Apps.  
+ *
+ * See also fb_connect.module for Facebook Connect.
  * 
  */
 
+// Option to require_login() on all canvas pages.
+define('FB_CANVAS_OPTION_ALLOW_ANON', 1);
+define('FB_CANVAS_OPTION_REQUIRE_LOGIN', 2);
 
+
 /**
  * implementation of hook_block
  *
@@ -78,7 +84,7 @@
     $fb_canvas_data = $fb_app_data['fb_canvas'];
     
     $is_canvas = FALSE;
-
+    
     // Set an app-specific theme.
     global $custom_theme; // Set by this function.
     if (fb_canvas_is_fbml()) {
@@ -89,12 +95,27 @@
       $custom_theme = $fb_canvas_data['theme_iframe'];
       $is_canvas = TRUE;
     }
-
-    // Hack to init the theme before _drupal_maintenance_theme initializes the wrong one.
-    if ($is_canvas && variable_get('site_offline', FALSE)) {
-      $dummy = theme('dummy');
+    
+    if ($is_canvas) {
+      // We are serving a canvas page.
+      if ($fb_canvas_data['require_login'] == FB_CANVAS_OPTION_REQUIRE_LOGIN) {
+        // The application is configured to require login on all canvas pages.
+        // However, there are exceptions.
+        if (isset($_REQUEST['fb_sig_in_profile_tab']) && $_REQUEST['fb_sig_in_profile_tab']) {
+          // Redirects are not allowed for the profile tab.
+        }
+        else {
+          // There may be other exceptions, for example some ajax callbacks.  Potential todo item.
+          $fb->require_login();
+        }
+      }
+      
+      // Hack to init the theme before _drupal_maintenance_theme initializes the wrong one.
+      if (variable_get('site_offline', FALSE)) {
+        $dummy = theme('dummy');
+      }
     }
-
+    
     // Special handling for forms, as they are submitted directly to us, not
     // to apps.facebook.com/canvas
     // we will buffer, and later cache, the results.
@@ -175,6 +196,21 @@
   }
 }
 
+/**
+ * Helper returns configuration for this module, on a per-app basis.
+ */
+function _fb_canvas_get_config($fb_app) {
+  $fb_app_data = fb_app_get_data($fb_app);
+  $fb_canvas_data = $fb_app_data['fb_canvas'] ? $fb_app_data['fb_canvas'] : array();
+  
+  // Merge in defaults
+  $fb_canvas_data += array(
+    'require_login' => FB_CANVAS_OPTION_ALLOW_ANON,
+    'theme_fbml' => 'fb_fbml',
+    'theme_iframe' => 'fb_fbml',
+  );
+  return $fb_canvas_data;
+}
 
 /**
  * Implementation of hook_form_alter.
@@ -183,23 +219,29 @@
   // Add our settings to the fb_app edit form.
   if (isset($form['fb_app_data']) && is_array($form['fb_app_data'])) {
     $node = $form['#node'];
-    $fb_app_data = fb_app_get_data($node->fb_app);
-    $fb_canvas_data = $fb_app_data['fb_canvas'];
+    $fb_canvas_data = _fb_canvas_get_config($node->fb_app);    
     
-    // defaults
-    if (!$fb_canvas_data)
-      $fb_canvas_data = array();
-    $fb_canvas_data = array_merge(array('theme_fbml' => 'fb_fbml',
-                                        'theme_iframe' => 0),
-                                  $fb_canvas_data);
+    $form['fb_app_data']['fb_canvas'] = array(
+      '#type' => 'fieldset',
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#title' => t('Facebook canvas pages'),
+      '#description' => t('Settings which apply to <a href=!url target=_blank>canvas pages</a>.',
+                          array('!url' => 'http://developers.facebook.com/get_started.php?tab=anatomy#canvas')),
+    );
     
+    $form['fb_app_data']['fb_canvas']['require_login'] = array(
+      '#type' => 'radios',
+      '#title' => t('Require authorization'),
+      '#description' => t('Require authorization if you want Drupal for Facebook to call require_login() on <strong>every</strong> canvas page.'),
+      '#options' => array(
+        FB_CANVAS_OPTION_ALLOW_ANON => t('Allow anonymous visitors'),
+        FB_CANVAS_OPTION_REQUIRE_LOGIN => t('Require all users to authorize the application'),
+      ),
+      '#default_value' => $fb_canvas_data['require_login'],
+      '#required' => TRUE,
+    );
     
-    $form['fb_app_data']['fb_canvas'] = array('#type' => 'fieldset',
-                                              '#collapsible' => TRUE,
-                                              '#collapsed' => TRUE,
-                                              '#title' => t('Facebook canvas page settings'),
-                                              '#description' => t('Allows application-specific front page and navigation links.')
-    );
     $form['fb_app_data']['fb_canvas']['front_anonymous'] =
       array('#type' => 'textfield',
             '#title' => t('Front page when user is not logged in to facebook'),
@@ -215,7 +257,7 @@
       );
     $form['fb_app_data']['fb_canvas']['front_added'] =
       array('#type' => 'textfield',
-            '#title' => t('Front page for users of this application'),
+            '#title' => t('Front page for authorized users of this application'),
             '#description' => t('Leave blank to use the site-wide front page.'),
             '#default_value' => $fb_canvas_data['front_added'],
       );
@@ -299,7 +341,7 @@
       $form['fb_canvas_form_handler']['#action_new'] = $form['#action'];
       // We've stored #action_old and #action_new so custom modules have the option to change it back.
     }
-
+    
     // Drupal includes wacky markup for javascript junk in node forms.  It
     // makes things look terrible in FBML.  It only works when javascript is
     // enabled and it should have been implemented to degrade gracefully, but
Index: fb_user.module
===================================================================
--- fb_user.module	(revision 2128)
+++ fb_user.module	(working copy)
@@ -9,9 +9,6 @@
  * application's canvas pages.
  */
 
-define('FB_USER_OPTION_ALLOW_ANON', 1);
-define('FB_USER_OPTION_REQUIRE_LOGIN', 2);
-
 define('FB_USER_OPTION_CREATE_NEVER', 1);
 define('FB_USER_OPTION_CREATE_LOGIN', 2);
 
@@ -34,7 +31,6 @@
 
   // Merge in defaults
   $fb_user_data += array(
-    'require_login' => FB_USER_OPTION_ALLOW_ANON,
     'create_account' => FB_USER_OPTION_CREATE_LOGIN,
     'map_account' => FB_USER_OPTION_MAP_ALWAYS,
   );
@@ -117,14 +113,8 @@
   if ($fb_app) {
     $fb_user_data = _fb_user_get_config($fb_app);
   }
-
-  if ($op == FB_OP_INITIALIZE) {
-    // Here we ask facebook to prompt the user to authorize the app.
-    if (fb_user_authentication_is_required($fb_app)) {
-      $fb->require_login();
-    }
-  }
-  else if ($op == FB_OP_POST_INIT) {
+  
+  if ($op == FB_OP_POST_INIT) {
     // Observe special rules for canvas page users without local accounts
     if (!$user->uid && !_fb_user_special_page() && !isset($_REQUEST['form_id'])) {
       if ($fbu = fb_facebook_user($fb) && fb_api_check_session($fb) && !$fb->api_client->users_isAppUser()) {
@@ -310,33 +300,6 @@
   }
 }
 
-/**
- * Determines whether authentication is required to serve the current
- * page.  This will return true if the application has been configured
- * to require login for all canvas pages.  Except in special cases,
- * such as profile tabs.
- *
- * @return TRUE only for canvas pages if authentication is required to
- * use the application and the page is not a special exception to the
- * rule.
- */
-function fb_user_authentication_is_required($fb_app) {
-  $fb_user_data = _fb_user_get_config($fb_app);
-  
-  if ($fb_user_data['require_login'] == FB_USER_OPTION_REQUIRE_LOGIN) {
-    // The application is configured to require login on all canvas pages.
-    // However, there are exceptions.
-    if (isset($_REQUEST['fb_sig_in_profile_tab']) && $_REQUEST['fb_sig_in_profile_tab']) {
-      // Redirects are not allowed for the profile tab.
-      return FALSE;
-    }
-    // There may be other exceptions, for example some ajax callbacks.  Potential todo item.
-    
-    // No exceptions apply, authentication is required.
-    return TRUE;
-  }
-}
-
 function fb_user_form_alter(&$form, &$form_state, $form_id) {
   // Add our settings to the fb_app edit form.
   if (isset($form['fb_app_data'])) {
@@ -349,20 +312,7 @@
                                             '#collapsible' => TRUE,
                                             '#collapsed' => TRUE,
     );
-    
-    $form['fb_app_data']['fb_user']['require_login'] = 
-      array('#type' => 'radios',
-            '#title' => t('Require Login'),
-            '#description' => t('If some of your canvas (or connect) pages are visible to the public at large, allow anyone.  You will have to call Facebook\'s require_login() on pages that require more information about the user.<br />Allow only logged-in users if you want Drupal for Facebook to call require_login() on every page.'),
-            '#options' => 
-            array(FB_USER_OPTION_ALLOW_ANON => t('Allow anyone'),
-                  FB_USER_OPTION_REQUIRE_LOGIN => t('Allow logged-in users'),
-            ),
-            '#default_value' => $fb_user_data['require_login'],
-            '#required' => TRUE,
-      );
-    
-    
+        
     $form['fb_app_data']['fb_user']['create_account'] = 
       array('#type' => 'radios',
             '#title' => t('Create Local Account'),
