From 7258969cd48d9e11e500db56665e190d05d1e4c0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 18 Jun 2008 23:36:19 -0400 Subject: use query method to do some transactions darcs-hash:20080619033619-84dde-e4fcc00f5d86cb0d11feff5f88f719ea72d3318e.gz --- actions/finishaddopenid.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'actions/finishaddopenid.php') 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')); } } -- cgit v1.2.3-54-g00ecf