? sites/default/files ? sites/default/settings.php Index: modules/openid/openid.css =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.css,v retrieving revision 1.5 diff -u -d -F^\s*function -r1.5 openid.css --- modules/openid/openid.css 30 Jan 2008 22:11:22 -0000 1.5 +++ modules/openid/openid.css 7 Sep 2008 20:41:09 -0000 @@ -1,43 +1,14 @@ /* $Id: openid.css,v 1.5 2008/01/30 22:11:22 goba Exp $ */ -#edit-openid-identifier { - background-image: url("login-bg.png"); - background-position: 0% 50%; - background-repeat: no-repeat; - padding-left: 20px; -} - -div#edit-openid-identifier-wrapper { - display: block; -} - -html.js #user-login-form div#edit-openid-identifier-wrapper, -html.js #user-login div#edit-openid-identifier-wrapper { - display: none; -} - -html.js #user-login-form li.openid-link, -html.js #user-login li.openid-link { - display : block; -} - -#user-login-form ul { - margin-top: 0; -} - -#user-login-form li.openid-link, -#user-login-form li.user-link, -#user-login li.openid-link, -#user-login li.user-link { - display: none; -} - -#user-login-form li.openid-link, -#user-login-form li.user-link { - text-align : left; +.openid-link { + background: url('login-bg.png') left center no-repeat; + padding-left: 18px; + margin-left: 0.2em; } -#user-login-form li.openid-link, -#user-login li.openid-link { - background: transparent url(login-bg.png) no-repeat scroll 1px 0.35em; +form.openid-enabled #edit-name { + background-image: url('login-bg.png'); + background-position: left center; + background-repeat: no-repeat; + padding-left:20px; } Index: modules/openid/openid.js =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.js,v retrieving revision 1.6 diff -u -d -F^\s*function -r1.6 openid.js --- modules/openid/openid.js 30 Jan 2008 22:11:22 -0000 1.6 +++ modules/openid/openid.js 7 Sep 2008 20:41:09 -0000 @@ -1,38 +1,16 @@ // $Id: openid.js,v 1.6 2008/01/30 22:11:22 goba Exp $ -Drupal.behaviors.openid = function (context) { - var $loginElements = $("#edit-name-wrapper, #edit-pass-wrapper, li.openid-link"); - var $openidElements = $("#edit-openid-identifier-wrapper, li.user-link"); +Drupal.behaviors.openIDLogin = function(context) { + var setOpenID = function() { + // OpenID-enable/disable the form based on the checkboxes' status. + $('#user-login, #user-login-form')[this.checked ? 'addClass' : 'removeClass']('openid-enabled'); + $('#edit-pass-wrapper')[this.checked ? 'slideUp' : 'slideDown']('fast'); + }; - // This behavior attaches by ID, so is only valid once on a page. - if (!$("#edit-openid-identifier.openid-processed").size() && $("#edit-openid-identifier").val()) { - $("#edit-openid-identifier").addClass('openid-processed'); - $loginElements.hide(); - // Use .css("display", "block") instead of .show() to be Konqueror friendly. - $openidElements.css("display", "block"); - } - $("li.openid-link:not(.openid-processed)", context) - .addClass('openid-processed') - .click( function() { - $loginElements.hide(); - $openidElements.css("display", "block"); - // Remove possible error message. - $("#edit-name, #edit-pass").removeClass("error"); - $("div.messages.error").hide(); - // Set focus on OpenID Identifier field. - $("#edit-openid-identifier")[0].focus(); - return false; - }); - $("li.user-link:not(.openid-processed)", context) - .addClass('openid-processed') - .click(function() { - $openidElements.hide(); - $loginElements.css("display", "block"); - // Clear OpenID Identifier field and remove possible error message. - $("#edit-openid-identifier").val('').removeClass("error"); - $("div.messages.error").css("display", "block"); - // Set focus on username field. - $("#edit-name")[0].focus(); - return false; - }); + $('#edit-use-openid:not(.openidlogin-processed)', context).each(function() { + // Mark the checkbox as processed and add the click handler. + var checkbox = $(this).addClass('openidlogin-processed').click(setOpenID); + // Call the function on load so that the form is adapted accordingly. + setOpenID.apply(checkbox.get(0)); + }); }; Index: modules/openid/openid.module =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.module,v retrieving revision 1.28 diff -u -d -F^\s*function -r1.28 openid.module --- modules/openid/openid.module 6 Sep 2008 08:36:20 -0000 1.28 +++ modules/openid/openid.module 7 Sep 2008 20:41:10 -0000 @@ -77,38 +77,26 @@ function openid_form_alter(&$form, $form if ($form_id == 'user_login_block' || $form_id == 'user_login') { drupal_add_css(drupal_get_path('module', 'openid') . '/openid.css', 'module'); drupal_add_js(drupal_get_path('module', 'openid') . '/openid.js'); - if (!empty($form_state['post']['openid_identifier'])) { - $form['name']['#required'] = FALSE; + + // Change the validate handler when the user wants to log in using OpenID. + if (!empty($form_state['post']) && (!empty($form_state['post']['use_openid']))) { $form['pass']['#required'] = FALSE; unset($form['#submit']); $form['#validate'] = array('openid_login_validate'); } - $items = array(); - $items[] = array( - 'data' => l(t('Log in using OpenID'), '#'), - 'class' => 'openid-link', - ); - $items[] = array( - 'data' => l(t('Cancel OpenID login'), '#'), - 'class' => 'user-link', - ); - - $form['openid_links'] = array( - '#markup' => theme('item_list', $items), - '#weight' => 1, + $form['use_openid'] = array( + '#type' => 'checkbox', + '#title' => t('Login using !openid-link', array('!openid-link' => l(t('OpenID'), 'http://openid.net', array('external' => TRUE, 'attributes' => array('class' => 'openid-link', 'title' => t('What is OpenID?'), 'tabindex' => 5))))), + '#weight' => 5, + '#attributes' => array('tabindex' => 3), ); - $form['links']['#weight'] = 2; + // Ensure a usable tab sequence. + $form['name']['#attributes']['tabindex'] = 1; + $form['pass']['#attributes']['tabindex'] = 2; + $form['submit']['#attributes']['tabindex'] = 4; - $form['openid_identifier'] = array( - '#type' => 'textfield', - '#title' => t('Log in using OpenID'), - '#size' => ($form_id == 'user_login') ? 58 : 13, - '#maxlength' => 255, - '#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()))); } elseif ($form_id == 'user_register' && isset($_SESSION['openid'])) { @@ -136,7 +124,16 @@ function openid_login_validate($form, &$ $return_to = url('', array('absolute' => TRUE)); } - openid_begin($form_state['values']['openid_identifier'], $return_to, $form_state['values']); + // Kick off OpenID login. + if (openid_begin($form_state['values']['name'], $return_to, $form_state['values']) === FALSE) { + // OpenID login failed. Choose an error message depending on the status. + if (!empty($form_state['values']['pass'])) { + form_set_error('name', t('You entered a password but chose to log in using OpenID. However, the OpenID was not valid. Please ensure you have spelled your ID correctly and that you really want to log in using OpenID.')); + } + else { + form_set_error('name', t('Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.')); + } + } } /** @@ -156,8 +153,7 @@ function openid_begin($claimed_id, $retu $services = openid_discovery($claimed_id); if (count($services) == 0) { - form_set_error('openid_identifier', t('Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.')); - return; + return FALSE; } // Store discovered information in the users' session so we don't have to rediscover. Index: modules/openid/openid.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.pages.inc,v retrieving revision 1.6 diff -u -d -F^\s*function -r1.6 openid.pages.inc --- modules/openid/openid.pages.inc 14 Apr 2008 17:48:38 -0000 1.6 +++ modules/openid/openid.pages.inc 7 Sep 2008 20:41:10 -0000 @@ -75,7 +75,9 @@ function openid_user_add_validate($form, } else { $return_to = url('user/' . arg(1) . '/openid', array('absolute' => TRUE)); - openid_begin($form_state['values']['openid_identifier'], $return_to); + if (openid_begin($form_state['values']['openid_identifier'], $return_to) === FALSE) { + form_set_error('openid_identifier', t('Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.')); + } } } Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.918 diff -u -d -F^\s*function -r1.918 user.module --- modules/user/user.module 6 Sep 2008 08:36:22 -0000 1.918 +++ modules/user/user.module 7 Sep 2008 20:41:11 -0000 @@ -686,22 +686,31 @@ function user_login_block() { '#maxlength' => USERNAME_MAX_LENGTH, '#size' => 15, '#required' => TRUE, + '#weight' => -10, ); $form['pass'] = array('#type' => 'password', '#title' => t('Password'), '#maxlength' => 60, '#size' => 15, '#required' => TRUE, + '#weight' => 0, ); $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'), + '#weight' => 10, ); + + // Add links to the login block allowing the user to register and retrieve + // a forgotten password. $items = array(); if (variable_get('user_register', 1)) { $items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.')))); } $items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.')))); - $form['links'] = array('#markup' => theme('item_list', $items)); + $form['links'] = array( + '#markup' => theme('item_list', $items), + '#weight' => 20, + ); return $form; } @@ -1225,6 +1234,7 @@ function user_login(&$form_state) { '#maxlength' => USERNAME_MAX_LENGTH, '#required' => TRUE, '#attributes' => array('tabindex' => '1'), + '#weight' => -10, ); $form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal'))); @@ -1233,9 +1243,15 @@ function user_login(&$form_state) { '#description' => t('Enter the password that accompanies your username.'), '#required' => TRUE, '#attributes' => array('tabindex' => '2'), + '#weight' => 0 ); $form['#validate'] = user_login_default_validators(); - $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'), '#weight' => 2, '#attributes' => array('tabindex' => '3')); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Log in'), + '#weight' => 10, + '#attributes' => array('tabindex' => '3') + ); return $form; }