X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ffinishaddopenid.php;h=35b82ddf9271182da51ee0773e8333f10085c90e;hb=d0559fdf4dafcaf8446b437f4af089c944a23d09;hp=bd9ecf7dd7356c626cc2a7f8176fe4e8a8142415;hpb=9eb05720a11d0cd3a55b9689067d13a1f00ba508;p=quix0rs-gnu-social.git diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php index bd9ecf7dd7..35b82ddf92 100644 --- a/actions/finishaddopenid.php +++ b/actions/finishaddopenid.php @@ -34,7 +34,7 @@ class FinishaddopenidAction extends Action { function try_login() { - $consumer = oid_consumer(); + $consumer =& oid_consumer(); $response = $consumer->complete(common_local_url('finishaddopenid')); @@ -58,18 +58,23 @@ class FinishaddopenidAction extends Action { $sreg = $sreg_resp->contents(); } - $user = $this->get_user($canonical); + common_debug(print_r($sreg, TRUE), __FILE__); + common_debug(print_r($display, TRUE), __FILE__); + common_debug(print_r($canonical, TRUE), __FILE__); + + $other =& $this->get_user($canonical); - if ($user) { - $this->message(_t('This OpenID is already associated with user "') . $user->nickname . _t('"')); + if ($other) { + $this->message(_t('This OpenID is already associated with user "') . $other->nickname . _t('"')); } else { - $user = common_current_user(); - if (!$this->connect_user($user, $display, $canonical)) { + $cur =& common_current_user(); + $result = oid_link_user($cur->id, $display, $canonical); + if (!$result) { $this->message(_t('Error connecting user')); return; } if ($sreg) { - if (!$this->update_user($user, $sreg)) { + if (!$this->update_user($cur, $sreg)) { $this->message(_t('Error updating profile')); return; } @@ -95,9 +100,9 @@ class FinishaddopenidAction extends Action { return $user; } - function update_user($user, $sreg) { + function update_user(&$user, $sreg) { - $profile = $user->getProfile(); + $profile =& $user->getProfile(); $orig_profile = clone($profile); @@ -136,19 +141,4 @@ class FinishaddopenidAction extends Action { return true; } - - function connect_user($user, $display, $canonical) { - - $oid = new User_openid(); - $oid->display = $display; - $oid->canonical = $canonical; - $oid->user_id = $user->id; - $oid->created = DB_DataObject_Cast::dateTime(); - - common_debug('Saving ' . print_r($oid, TRUE), __FILE__); - - if (!$oid->insert()) { - return false; - } - } }