diff --git a/email_registration.install b/email_registration.install
index 3522ae1..1190491 100644
--- a/email_registration.install
+++ b/email_registration.install
@@ -23,3 +23,10 @@ function email_registration_requirements() {
 
   return $requirements;
 }
+
+/**
+ * Implements hook_uninstall().
+ */
+function email_registration_uninstall() {
+  variable_del('email_registration_login_with_username');
+}
diff --git a/email_registration.module b/email_registration.module
index f74784a..523b316 100644
--- a/email_registration.module
+++ b/email_registration.module
@@ -95,12 +95,37 @@ function email_registration_form_user_login_block_alter(&$form, &$form_state) {
 }
 
 /**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function email_registration_form_user_admin_settings_alter(&$form, &$form_state) {
+  $form['registration_cancellation']['email_registration_login_with_username'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Let users login with e-mail or username'),
+    '#description' => t('Allow users to login with either email or username'),
+    '#default_value' => variable_get('email_registration_login_with_username', FALSE),
+    );
+  $form['#submit'][] = 'email_registration_form_user_admin_settings_submit';
+}
+
+/**
+ * Submit function for user_admin_settings to save our variable.
+ *
+ * @see email_registration_form_user_admin_settings_alter().
+ */
+function email_registration_form_user_admin_settings_submit($form, &$form_state) {
+  variable_set('email_registration_login_with_username', $form_state['values']['email_registration_login_with_username']);
+}
+
+/**
  * Form element validation handler for the user login form.
  * Allows users to authenticate by email, which is our preferred method.
  */
 function email_registration_user_login_validate($form, &$form_state) {
   if (isset($form_state['values']['name'])) {
-    if ($name = db_query('SELECT name FROM {users} WHERE LOWER(mail) = LOWER(:name)', array(':name' => $form_state['values']['name']))->fetchField()) {
+    $name = db_query('SELECT name FROM {users} WHERE LOWER(mail) = LOWER(:name)', array(':name' => $form_state['values']['name']))->fetchField();
+    // If the name matches a mail assume that it's the desired name.
+    // OR, if they are only allowed to use email then always overwrite even if it's with an empty string.
+    if (!empty($name) || !variable_get('email_registration_login_with_username', FALSE)) {
       $form_state['values']['name'] = $name;
     }
   }
diff --git a/email_registration.test b/email_registration.test
index ea5a8a4..e592c45 100644
--- a/email_registration.test
+++ b/email_registration.test
@@ -52,5 +52,16 @@ class EmailRegistrationTestCase extends DrupalWebTestCase {
     // Really basic confirmatino that the user was created and logged in.
     $this->assertRaw('<title>' . $name . ' | Drupal</title>', t('User properly created, logged in.'));
 
+    // Try to login with just username, should fail by default.
+    $this->drupalLogout();
+    $login['name'] = $name;
+    $this->drupalPost('user/login', $login, t('Log in'));
+    $this->assertRaw('<title>User account | Drupal</title>', t('By default a user cannot login with just their username'));
+
+    // Allow logins with username and try to login with just username, should work.
+    variable_set('email_registration_login_with_username', TRUE);
+    $this->drupalPost('user/login', $login, t('Log in'));
+    $this->assertRaw('<title>' . $name . ' | Drupal</title>', t('User properly created, logged in.'));
+
   }
 }
