better error handling

darcs-hash:20080618071207-84dde-a7903c5a806e16a39101244ef721204a7ce2bd46.gz
This commit is contained in:
Evan Prodromou 2008-06-18 03:12:07 -04:00
parent 7a17d1c477
commit ec68ae3cb1

View File

@ -64,10 +64,17 @@ class FinishaddopenidAction extends Action {
$this->message(_t('This OpenID is already associated with user "') . $user->nickname . _t('"'));
} else {
$user = common_current_user();
$this->connect_user($user, $display, $canonical);
if ($sreg) {
$this->update_user($user, $sreg);
if (!$this->connect_user($user, $display, $canonical)) {
$this->message(_t('Error connecting user'));
return;
}
if ($sreg) {
if (!$this->update_user($user, $sreg)) {
$this->message(_t('Error updating profile'));
return;
}
}
# success!
common_redirect(common_local_url('openidsettings'));
}
}
@ -113,7 +120,7 @@ class FinishaddopenidAction extends Action {
if (!$profile->update($orig_profile)) {
common_server_error(_t('Error saving the profile.'));
return;
return false;
}
$orig_user = clone($user);
@ -124,8 +131,10 @@ class FinishaddopenidAction extends Action {
if (!$user->update($orig_user)) {
common_server_error(_t('Error saving the user.'));
return;
return false;
}
return true;
}
function connect_user($user, $display, $canonical) {
@ -137,8 +146,7 @@ class FinishaddopenidAction extends Action {
$oid->created = DB_DataObject_Cast::dateTime();
if (!$oid->insert()) {
common_server_error(_t('Error connecting OpenID.'));
return;
return false;
}
}
}