summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-06-18 07:43:10 -0400
committerEvan Prodromou <evan@prodromou.name>2008-06-18 07:43:10 -0400
commit4a0b1a9ea9d288e42ac03c43ef904b0565a7087f (patch)
tree2e18913f029cd0b696b7d80504b5277867f4ea5c /actions
parentdc2e7f4225acb216ec715d6c960dd53c7a318e54 (diff)
consolidate linking a user to an OpenID
darcs-hash:20080618114310-84dde-15b224bb16d434150af457bc3b08de58e3833abd.gz
Diffstat (limited to 'actions')
-rw-r--r--actions/finishaddopenid.php23
-rw-r--r--actions/finishopenidlogin.php19
2 files changed, 6 insertions, 36 deletions
diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php
index 2b34b38ea..6a7bb3d24 100644
--- a/actions/finishaddopenid.php
+++ b/actions/finishaddopenid.php
@@ -64,7 +64,8 @@ class FinishaddopenidAction extends Action {
$this->message(_t('This OpenID is already associated with user "') . $user->nickname . _t('"'));
} else {
$cur = common_current_user();
- if (!$this->connect_user($cur, $display, $canonical)) {
+ $result = oid_link_user($cur->id, $display, $canonical);
+ if (!$result) {
$this->message(_t('Error connecting user'));
return;
}
@@ -136,24 +137,4 @@ class FinishaddopenidAction extends Action {
return true;
}
-
- function connect_user($user, $display, $canonical) {
-
- $id = $user->id;
-
- $oid = new User_openid();
- $oid->display = $display;
- $oid->canonical = $canonical;
- $oid->user_id = $id;
- $oid->created = DB_DataObject_Cast::dateTime();
-
- $result = $oid->insert();
-
- if (!$result) {
- $err = PEAR::getStaticProperty('DB_DataObject','lastError');
- common_debug('DB error ' . $err->code . ': ' . $err->message, __FILE__);
- return false;
- }
- return true;
- }
}
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index 202520d54..3d0c8f277 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -264,15 +264,8 @@ class FinishopenidloginAction extends Action {
$profile->delete();
}
- $oid = new User_openid();
- $oid->display = $display;
- $oid->canonical = $canonical;
- $oid->user_id = $id;
- $oid->created = DB_DataObject_Cast::dateTime();
- $result = $oid->insert();
-
- if (!$result) {
+ if (!oid_link_user($user->id, $canonical, $display) {
# Try to clean up...
$user->delete();
$profile->delete();
@@ -303,14 +296,10 @@ class FinishopenidloginAction extends Action {
return;
}
- $oid = new User_openid();
- $oid->display = $display;
- $oid->canonical = $canonical;
- $oid->user_id = $user->id;
- $oid->created = DB_DataObject_Cast::dateTime();
+ $result = oid_link_user($user->id, $canonical, $display);
- if (!$oid->insert()) {
- common_server_error(_t('Error connecting OpenID.'));
+ if (!$result) {
+ common_server_error(_t('Error connecting user to OpenID.'));
return;
}