aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-01-28 12:40:18 -0500
committerCash Costello <cash.costello@gmail.com>2012-01-28 12:40:18 -0500
commit20b29861d4ab48ad3f80925906ee70eb89ccddbc (patch)
tree0db92e7098dd3f4bddb71ec73a52722c65d84ecf
parent11a7ca1c5c23af990422783b14d021a7c177032b (diff)
downloadelgg-20b29861d4ab48ad3f80925906ee70eb89ccddbc.tar.gz
elgg-20b29861d4ab48ad3f80925906ee70eb89ccddbc.tar.bz2
supporting associating an OpenID with an existing account
-rw-r--r--return.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/return.php b/return.php
index 87ce5b19f..ab0fc622a 100644
--- a/return.php
+++ b/return.php
@@ -24,16 +24,29 @@ if (!$data || !$data['openid_identifier']) {
forward();
}
-// does this user exist
+// is there an account already associated with this openid
+$user = null;
$users = elgg_get_entities_from_annotations(array(
'type' => 'user',
'annotation_name' => 'openid_identifier',
'annotation_value' => $data['openid_identifier'],
));
if ($users) {
- // log in user and maybe update account (admin setting, user prompt?)
+ // there should only be one account
$user = $users[0];
+} else {
+ $email = elgg_extract('email', $data);
+ if ($email) {
+ $users = get_user_by_email($email);
+ if (count($users) === 1) {
+ $user = $users[0];
+ $user->annotate('openid_identifier', $data['openid_identifier'], ACCESS_PUBLIC);
+ }
+ }
+}
+if ($user) {
+ // log in user and maybe update account (admin setting, user prompt?)
try {
login($user);
} catch (LoginException $e) {