/[drupal]/contributions/modules/openid/openid.module
ViewVC logotype

Diff of /contributions/modules/openid/openid.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2.2.4, Sat Jul 28 03:05:47 2007 UTC revision 1.2.2.5, Sun Oct 14 20:19:21 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: openid.module,v 1.2.2.3 2007/05/24 15:01:21 walkah Exp $  // $Id: openid.module,v 1.2.2.4 2007/07/28 03:05:47 walkah Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 57  function openid_help($section) { Line 57  function openid_help($section) {
57    switch ($section) {    switch ($section) {
58      case 'user/'. arg(1) .'/openid':      case 'user/'. arg(1) .'/openid':
59        return t('You may login to this site using an OpenID. You may add your OpenId URLs below, and also see a list of any OpenIDs which have already been added.');        return t('You may login to this site using an OpenID. You may add your OpenId URLs below, and also see a list of any OpenIDs which have already been added.');
60        case 'admin/help#openid':
61          $output = '<p>'. t('OpenID is a secure way to use one user ID and password to log in to many web sites without special software, giving the same password to each site, or losing control over which information is shared with each site that you visit.') .'</p>';
62          $output .= '<p>'. t('Users can create accounts using their OpenID, assign one or more OpenIDs to an existing account, and log in using an OpenID. This lowers the barrier to registration, which is good for the site, and offers convenience and security to the users. Logging in via OpenID is far more secure than cross-site logins using drupal.module.') .'</p>';
63          $output .= '<p>'. t('More information on OpenID is available at <a href="@url">OpenID.net</a>', array('@url' => url('http://openid.net'))) .'</p>';
64          return $output;
65    }    }
66  }  }
67    
# Line 94  function openid_form_alter($form_id, &$f Line 99  function openid_form_alter($form_id, &$f
99      $form['openid_url'] = array(      $form['openid_url'] = array(
100        '#type' => 'textfield',        '#type' => 'textfield',
101        '#title' => t('Log in using OpenID'),        '#title' => t('Log in using OpenID'),
       '#default_value' => '',  
102        '#size' => ($form_id == 'user_login') ? 58 : 13,        '#size' => ($form_id == 'user_login') ? 58 : 13,
103        '#maxlength' => 255,        '#maxlength' => 255,
104        '#weight' => -1,        '#weight' => -1,
# Line 102  function openid_form_alter($form_id, &$f Line 106  function openid_form_alter($form_id, &$f
106        '#prefix' => '<div id="edit-openid-url-wrapper">',        '#prefix' => '<div id="edit-openid-url-wrapper">',
107        '#suffix' => '</div>'        '#suffix' => '</div>'
108        );        );
109      $form['openid.return_to'] = array('#type' => 'hidden', '#value' => url('openid/authenticate', NULL, NULL, TRUE));      $form['openid.return_to'] = array('#type' => 'hidden', '#value' => url('openid/authenticate', drupal_get_destination(), NULL, TRUE));
110      $form['name']['#prefix'] = '<div id="edit-name-wrapper">';      $form['name']['#prefix'] = '<div id="edit-name-wrapper">';
111      $form['name']['#suffix'] = '</div>';      $form['name']['#suffix'] = '</div>';
112      $form['pass']['#prefix'] = '<div id="edit-pass-wrapper">';      $form['pass']['#prefix'] = '<div id="edit-pass-wrapper">';
# Line 219  function openid_begin($claimed_id, $retu Line 223  function openid_begin($claimed_id, $retu
223    
224    $services = openid_discovery($claimed_id);    $services = openid_discovery($claimed_id);
225    if (count($services) == 0) {    if (count($services) == 0) {
226      drupal_set_message(t('Unable authenticate. OpenID Discovery failed.'), 'error');      form_set_error('openid_url', t('Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.'));
227      return;      return;
228    }    }
229    
# Line 356  function openid_discovery($claimed_id) { Line 360  function openid_discovery($claimed_id) {
360  }  }
361    
362  /**  /**
363   * Attempt to create a shared secrete with the OpenID Provider.   * Attempt to create a shared secret with the OpenID Provider.
364   *   *
365   * @param $op_endpoint URL of the OpenID Provider endpoint.   * @param $op_endpoint URL of the OpenID Provider endpoint.
366   *   *
# Line 427  function openid_authentication($response Line 431  function openid_authentication($response
431        drupal_set_message(t('You must validate your email address for this account before logging in via OpenID'));        drupal_set_message(t('You must validate your email address for this account before logging in via OpenID'));
432      }      }
433    }    }
434    else {    elseif (variable_get('user_register', 1)) {
435      // Register new user      // Register new user
436      $form = drupal_retrieve_form('user_register');      $form = drupal_retrieve_form('user_register');
437      $edit['name'] = (empty($response['openid.sreg.nickname'])) ? $identity : $response['openid.sreg.nickname'];      $edit['name'] = (empty($response['openid.sreg.nickname'])) ? $identity : $response['openid.sreg.nickname'];
# Line 457  function openid_authentication($response Line 461  function openid_authentication($response
461        user_login_submit('user_login', array());        user_login_submit('user_login', array());
462      }      }
463    }    }
464      else {
465        drupal_set_message(t('Only site administrators can create new user accounts.'), 'error');
466      }
467    drupal_goto();    drupal_goto();
468  }  }
469    
# Line 533  function openid_verify_assertion($op_end Line 540  function openid_verify_assertion($op_end
540      if ($self_sig == $response['openid.sig']) {      if ($self_sig == $response['openid.sig']) {
541        $valid = TRUE;        $valid = TRUE;
542      }      }
     else {  
       $valid = FALSE;  
     }  
543    }    }
544    else {    else {
545      $request = $response;      $request = $response;
# Line 543  function openid_verify_assertion($op_end Line 547  function openid_verify_assertion($op_end
547      $message = _openid_create_message($request);      $message = _openid_create_message($request);
548      $headers = array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8');      $headers = array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8');
549      $result = drupal_http_request($op_endpoint, $headers, 'POST', _openid_encode_message($message));      $result = drupal_http_request($op_endpoint, $headers, 'POST', _openid_encode_message($message));
550      $response = _openid_parse_message($result->data);      if (!isset($result->error)) {
551      if (strtolower(trim($response['is_valid'])) == 'true') {        $response = _openid_parse_message($result->data);
552        $valid = TRUE;        if (strtolower(trim($response['is_valid'])) == 'true') {
553      }          $valid = TRUE;
554      else {        }
       $valid = FALSE;  
555      }      }
556    }    }
557    

Legend:
Removed from v.1.2.2.4  
changed lines
  Added in v.1.2.2.5

  ViewVC Help
Powered by ViewVC 1.1.2