Commit 1d6be6f0 authored by Gábor Hojtsy's avatar Gábor Hojtsy

#153372 by bjaspan: fix user login form values and openid interacion

parent 48a04f26
......@@ -368,7 +368,7 @@ function _openid_get_bytes($num_bytes) {
if (!isset($f)) {
$f = @fopen(OPENID_RAND_SOURCE, "r");
}
if (!isset($f)) {
if (!$f) {
// pseudorandom used
$bytes = '';
for ($i = 0; $i < $num_bytes; $i += 4) {
......
......@@ -108,7 +108,7 @@ function openid_login_validate($form, &$form_state) {
$return_to = url('', array('absolute' => TRUE));
}
openid_begin($form_state['values']['openid_url'], $return_to);
openid_begin($form_state['values']['openid_url'], $return_to, $form_state['values']);
}
/**
......@@ -191,7 +191,7 @@ function openid_user_delete($account, $aid = 0) {
* @param $claimed_id The OpenID to authenticate
* @param $return_to The endpoint to return to from the OpenID Provider
*/
function openid_begin($claimed_id, $return_to = '') {
function openid_begin($claimed_id, $return_to = '', $form_values = array()) {
include_once drupal_get_path('module', 'openid') .'/openid.inc';
$claimed_id = _openid_normalize($claimed_id);
......@@ -207,6 +207,9 @@ function openid_begin($claimed_id, $return_to = '') {
$_SESSION['openid_op_endpoint'] = $op_endpoint;
// Store the claimed_id in the session (for handling delegation).
$_SESSION['openid_claimed_id'] = $claimed_id;
// Store the login form values so we can pass them to
// user_exteral_login later.
$_SESSION['openid_user_login_values'] = $form_values;
// If bcmath is present, then create an association
$assoc_handle = '';
......@@ -398,7 +401,7 @@ function openid_authentication($response) {
$account = user_external_load($identity);
if (isset($account->uid)) {
if (!variable_get('user_email_verification', TRUE) || $account->login) {
user_external_login($account);
user_external_login($account, $_SESSION['openid_user_login_values']);
}
else {
drupal_set_message(t('You must validate your email address for this account before logging in via OpenID'));
......
......@@ -80,22 +80,28 @@ function user_external_load($authname) {
}
/**
* Perform standard Drupal login operations for a user object. The
* user object must already be authenticated. This function verifies
* that the user account is not blocked/denied and then performs the login,
* updates the login timestamp in the database, invokes hook_user('login'),
* regenerates the session, etc.
*
* @param $account
* An authenticated user object to be set as the currently logged
* in user.
* @return boolean
* TRUE if the login succeeds, FALSE otherwise.
*/
function user_external_login($account) {
* Perform standard Drupal login operations for a user object. The
* user object must already be authenticated. This function verifies
* that the user account is not blocked/denied and then performs the login,
* updates the login timestamp in the database, invokes hook_user('login'),
* regenerates the session, etc.
*
* @param $account
* An authenticated user object to be set as the currently logged
* in user.
* @param $edit
* The array of form values submitted by the user, if any.
* @return boolean
* TRUE if the login succeeds, FALSE otherwise.
*/
function user_external_login($account, $edit = array()) {
$form = drupal_get_form('user_login');
$state = array();
$state['values'] = $edit;
if (empty($state['values']['name'])) {
$state['values']['name'] = $account->name;
}
user_login_name_validate($form, $state, (array)$account);
if (form_get_errors()) {
return FALSE;
......@@ -1075,7 +1081,7 @@ function user_login_default_validators() {
*
* @return void
**/
function user_login_name_validate($form, &$form_state) {
function user_login_name_validate($form, &$form_state) {
if (isset($form_state['values']['name'])) {
if (user_is_blocked($form_state['values']['name'])) {
// blocked in user administration
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment