summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/openid/openid.inc24
-rw-r--r--modules/openid/openid.module4
-rw-r--r--modules/openid/openid.test8
3 files changed, 21 insertions, 15 deletions
diff --git a/modules/openid/openid.inc b/modules/openid/openid.inc
index 74cd7c494..4d4163805 100644
--- a/modules/openid/openid.inc
+++ b/modules/openid/openid.inc
@@ -658,22 +658,26 @@ function openid_extract_namespace($response, $extension_namespace, $fallback_pre
*
* @param $values
* An array as returned by openid_extract_namespace(..., OPENID_NS_AX).
- * @param $aliases
- * An array of aliases used in the fetch request.
+ * @param $uris
+ * An array of identifier URIs.
* @return
* An array of values.
* @see http://openid.net/specs/openid-attribute-exchange-1_0.html#fetch_response
*/
-function openid_extract_ax_values($values, $aliases) {
+function openid_extract_ax_values($values, $uris) {
$output = array();
- foreach ($aliases as $alias) {
- if (isset($values['count.' . $alias])) {
- for ($i = 1; $i <= $values['count.' . $alias]; $i++) {
- $output[] = $values['value.' . $alias . '.' . $i];
+ foreach ($values as $key => $value) {
+ if (in_array($value, $uris) && preg_match('/^type\.([^.]+)$/', $key, $matches)) {
+ $alias = $matches[1];
+ if (isset($values['count.' . $alias])) {
+ for ($i = 1; $i <= $values['count.' . $alias]; $i++) {
+ $output[] = $values['value.' . $alias . '.' . $i];
+ }
}
- }
- elseif (isset($values['value.' . $alias])) {
- $output[] = $values['value.' . $alias];
+ elseif (isset($values['value.' . $alias])) {
+ $output[] = $values['value.' . $alias];
+ }
+ break;
}
}
return $output;
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index a6f2cd6d0..9a6e7edfb 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -175,7 +175,7 @@ function openid_form_user_register_form_alter(&$form, &$form_state) {
// Use the nickname returned by Simple Registration if available.
$form['account']['name']['#default_value'] = $sreg_values['nickname'];
}
- elseif ($ax_name_values = openid_extract_ax_values($ax_values, array('name_ao', 'name_son'))) {
+ elseif ($ax_name_values = openid_extract_ax_values($ax_values, array('http://axschema.org/namePerson/friendly', 'http://schema.openid.net/namePerson/friendly'))) {
// Else, use the first nickname returned by AX if available.
$form['account']['name']['#default_value'] = current($ax_name_values);
}
@@ -187,7 +187,7 @@ function openid_form_user_register_form_alter(&$form, &$form_state) {
// Use the email returned by Simple Registration if available.
$form['account']['mail']['#default_value'] = $sreg_values['email'];
}
- elseif ($ax_mail_values = openid_extract_ax_values($ax_values, array('mail_ao', 'mail_son'))) {
+ elseif ($ax_mail_values = openid_extract_ax_values($ax_values, array('http://axschema.org/contact/email', 'http://schema.openid.net/contact/email'))) {
// Else, use the first nickname returned by AX if available.
$form['account']['mail']['#default_value'] = current($ax_mail_values);
}
diff --git a/modules/openid/openid.test b/modules/openid/openid.test
index 49f390b12..cf90161fd 100644
--- a/modules/openid/openid.test
+++ b/modules/openid/openid.test
@@ -392,9 +392,11 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase {
// Tell openid_test.module to respond with these AX fields.
variable_set('openid_test_response', array(
'openid.ns.ext123' => 'http://openid.net/srv/ax/1.0',
- 'openid.ext123.value.mail_ao' => 'john@example.com',
- 'openid.ext123.count.name_son' => '1',
- 'openid.ext123.value.name_son.1' => 'john',
+ 'openid.ext123.type.mail456' => 'http://axschema.org/contact/email',
+ 'openid.ext123.value.mail456' => 'john@example.com',
+ 'openid.ext123.type.name789' => 'http://schema.openid.net/namePerson/friendly',
+ 'openid.ext123.count.name789' => '1',
+ 'openid.ext123.value.name789.1' => 'john',
));
// Use a User-supplied Identity that is the URL of an XRDS document.