summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/finishaddopenid.php22
-rw-r--r--actions/profilesettings.php7
-rw-r--r--lib/openid.php4
3 files changed, 22 insertions, 11 deletions
diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php
index 9ba3189b3..237f0454f 100644
--- a/actions/finishaddopenid.php
+++ b/actions/finishaddopenid.php
@@ -55,9 +55,23 @@ class FinishaddopenidAction extends Action {
if ($sreg_resp) {
$sreg = $sreg_resp->contents();
}
-
+
$cur =& common_current_user();
- common_debug('cur = ' .print_r($cur, TRUE), __FILE__);
+ $other = $this->get_user($canonical);
+
+ if ($other) {
+ if ($other->id == $cur->id) {
+ $this->message(_t('You already have this OpenID!'));
+ } else {
+ $this->message(_t('Someone else already has this OpenID.'));
+ }
+ return;
+ }
+
+ # start a transaction
+
+ $cur->query('BEGIN');
+
$result = oid_link_user($cur->id, $display, $canonical);
if (!$result) {
@@ -70,7 +84,11 @@ class FinishaddopenidAction extends Action {
return;
}
}
+
# success!
+
+ $cur->query('COMMIT');
+
common_redirect(common_local_url('openidsettings'));
}
}
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index 159dab18a..75e3758ab 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -112,16 +112,13 @@ class ProfilesettingsAction extends SettingsAction {
$user = common_current_user();
assert(!is_null($user)); # should already be checked
- # FIXME: transaction!
-
+ $user->query('BEGIN');
+
$original = clone($user);
$user->nickname = $nickname;
$user->email = $email;
- common_debug('Updating, nickname ="'.$user->nickname.'" and email ="'.$user->email.'"');
- common_debug('Original, nickname ="'.$original->nickname.'" and email ="'.$original->email.'"');
-
$result = $user->update($original);
if (!$result) {
diff --git a/lib/openid.php b/lib/openid.php
index f5f98201d..67f8edf7b 100644
--- a/lib/openid.php
+++ b/lib/openid.php
@@ -57,10 +57,6 @@ function oid_link_user($id, $canonical, $display) {
return false;
}
- # For some reason, autocommit is turned off
-
- $oid->query('COMMIT');
-
return true;
}