Skip to content
Snippets Groups Projects
Commit 1d6be6f0 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

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

parent 48a04f26
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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'));
......
......@@ -89,13 +89,19 @@ function user_external_load($authname) {
* @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) {
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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment