]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/finishaddopenid.php
consolidate linking a user to an OpenID
[quix0rs-gnu-social.git] / actions / finishaddopenid.php
index bd9ecf7dd7356c626cc2a7f8176fe4e8a8142415..6a7bb3d2484cc703dea65e4948d725ec824581e5 100644 (file)
@@ -58,18 +58,19 @@ class FinishaddopenidAction extends Action {
                                $sreg = $sreg_resp->contents();
                        }
 
-                       $user = $this->get_user($canonical);
+                       $other = $this->get_user($canonical);
 
-                       if ($user) {
+                       if ($other) {
                                $this->message(_t('This OpenID is already associated with user "') . $user->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;
                                        }
@@ -136,19 +137,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;
-               }
-       }
 }