* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!common_logged_in()) {
common_set_returnto($this->selfUrl());
common_redirect(common_local_url('login'));
if (!common_logged_in()) {
common_set_returnto($this->selfUrl());
common_redirect(common_local_url('login'));
}
$code = $this->trimmed('code');
if (!$code) {
// TRANS: Client error displayed when not providing a confirmation code in the contact address confirmation action.
}
$code = $this->trimmed('code');
if (!$code) {
// TRANS: Client error displayed when not providing a confirmation code in the contact address confirmation action.
- $this->clientError(_('Confirmation code not found.'));
- return;
+ throw new ClientException(_('Confirmation code not found.'), 404);
+ }
+
+ try {
+ $profile = Profile::getByID($confirm->user_id);
+ } catch (NoResultException $e) {
+ common_log(LOG_INFO, 'Tried to confirm the email for a deleted profile: '._ve(['id'=>$confirm->user_id, 'email'=>$confirm->address]));
+ $confirm->delete();
+ throw $e;
$type = $confirm->address_type;
$transports = array();
Event::handle('GetImTransports', array(&$transports));
if (!in_array($type, array('email', 'sms')) && !in_array($type, array_keys($transports))) {
// TRANS: Server error for an unknown address type, which can be 'email', 'sms', or the name of an IM network (such as 'xmpp' or 'aim')
$type = $confirm->address_type;
$transports = array();
Event::handle('GetImTransports', array(&$transports));
if (!in_array($type, array('email', 'sms')) && !in_array($type, array_keys($transports))) {
// TRANS: Server error for an unknown address type, which can be 'email', 'sms', or the name of an IM network (such as 'xmpp' or 'aim')
- if (in_array($type, array('email', 'sms')))
- {
+ if (in_array($type, array('email', 'sms'))) {
+ common_debug("Confirming {$type} address for user {$this->scoped->getID()}");
- // TRANS: Client error for an already confirmed email/jabber/sms address.
- $this->clientError(_('That address has already been confirmed.'));
- return;
+ // Already verified, so delete the confirm_address entry
+ $confirm->delete();
+ // TRANS: Client error for an already confirmed email/jabber/sms address.
+ throw new AlreadyFulfilledException(_('That address has already been confirmed.'));
- $result = $cur->updateKeys($orig_user);
-
- if (!$result) {
- common_log_db_error($cur, 'UPDATE', __FILE__);
- $this->serverError(_('Couldn\'t update user.'));
- return;
- }
+ // Throws exception on failure.
+ $cur->updateWithKeys($orig_user);
$user_im_prefs->user_id = $cur->id;
if ($user_im_prefs->find() && $user_im_prefs->fetch()) {
if($user_im_prefs->screenname == $confirm->address){
$user_im_prefs->user_id = $cur->id;
if ($user_im_prefs->find() && $user_im_prefs->fetch()) {
if($user_im_prefs->screenname == $confirm->address){
- $this->clientError(_('That address has already been confirmed.'));
- return;
+ // Already verified, so delete the confirm_address entry
+ $confirm->delete();
+ // TRANS: Client error for an already confirmed IM address.
+ throw new AlreadyFulfilledException(_('That address has already been confirmed.'));
- $result = $confirm->delete();
-
- if (!$result) {
- common_log_db_error($confirm, 'DELETE', __FILE__);
- // TRANS: Server error displayed when an address confirmation code deletion from the
- // TRANS: database fails in the contact address confirmation action.
- $this->serverError(_('Could not delete address confirmation.'));
- return;
- }
$this->element('p', null,
// TRANS: Success message for the contact address confirmation action.
// TRANS: %s can be 'email', 'jabber', or 'sms'.
$this->element('p', null,
// TRANS: Success message for the contact address confirmation action.
// TRANS: %s can be 'email', 'jabber', or 'sms'.