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) {
return;
}
}
+
# success!
+
+ $cur->query('COMMIT');
+
common_redirect(common_local_url('openidsettings'));
}
}
$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) {