--- OLD_commerce_checkout_login.module	Thu Jan 19 06:37:49 2012
+++ commerce_checkout_login.module	Thu Feb 23 15:14:23 2012
@@ -5,6 +5,37 @@
  * Adds an inline login form to the Account Information checkout pane.
  */
 
+/**
+ * Implement hook_menu().
+ */
+function commerce_checkout_login_menu() {
+  $items = array();
+
+  $items['admin/commerce/config/commerce_checkout_login'] = array(
+    'title' => 'Commerce Checkout Login',
+    'description' => 'Configuration for the Commerce Checkout Login module.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('commerce_checkout_login_settings'),
+    'access arguments' => array('access administration pages'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+
+ return $items;
+}
+
+/**
+  * Hook implementation of hook_settings().
+  */
+function commerce_checkout_login_settings($form, &$form_state) {
+  $form['commerce_checkout_login_password_required'] = array(
+    '#title' => t('Password required for existing accounts.'),
+    '#description' => t('Users must provide password for account is linked to the provided e-mail.'),
+    '#type' => 'checkbox',
+    '#default_value' => variable_get('commerce_checkout_login_password_required', false),
+  );
+
+  return system_settings_form($form);
+}
 
 /**
  * Implements hook_form_FORM_ID_alter().
@@ -38,9 +69,16 @@
         // message letting the customer know this.
         $form['account']['login']['mail']['#description'] = t('There is already an account registered to %mail. You can login now to use your account information during checkout.', array('%mail' => $mail));
 
+        // Check if users must login accounts that currently linked to the provided e-mail.
+        $password_required = false;   
+        if (variable_get('commerce_checkout_login_password_required', false)) {
+          $password_required = true;
+        }
+        
         $form['account']['login']['password'] = array(
           '#type' => 'password',
           '#title' => t('Password'),
+          '#required' => $password_required,
         );
 
         $form['account']['login']['login_now'] = array(
@@ -106,3 +144,28 @@
     unset($form_state['commerce_checkout_login_uid']);
   }
 }
+
+/**
+ * Hook implementation of hook_form_alter().
+ */
+function commerce_checkout_login_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {
+  // Check if users must login accounts that currently linked to the provided e-mail.
+  if (variable_get('commerce_checkout_login_password_required', false)) {
+    $form['buttons']['continue']['#validate'][] = 'commerce_checkout_login_commerce_checkout_form_checkout_login_validate';
+  }
+}
+
+/**
+ * Function to ensure user has been logged in before continuing checkout.
+ */
+function commerce_checkout_login_commerce_checkout_form_checkout_login_validate(&$form, &$form_state) {
+  global $user;
+
+  // If the password field is present and the setting is enabled - ensure the user is logged in.
+  if (!@empty($form['account']['login']['password'])) {
+    if ($user->uid <= 0) {
+      form_set_error('account][login][password', t('Please enter your account password or use a different e-mail address.'));    
+    }
+  }
+  
+}
\ No newline at end of file
