Initial user doesn't need as strict checking on email
This commit is contained in:
parent
67801a5566
commit
bdc38a7204
@ -207,7 +207,7 @@ class User extends Managed_DataObject
|
||||
* @return User object
|
||||
* @throws Exception on failure
|
||||
*/
|
||||
static function register(array $fields) {
|
||||
static function register(array $fields, $accept_email_fail=false) {
|
||||
|
||||
// MAGICALLY put fields into current scope
|
||||
|
||||
@ -371,8 +371,15 @@ class User extends Managed_DataObject
|
||||
|
||||
$profile->query('COMMIT');
|
||||
|
||||
if (!empty($email) && !$user->email) {
|
||||
mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
|
||||
if (!empty($email) && !empty($user->email)) {
|
||||
try {
|
||||
mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
|
||||
} catch (EmailException $e) {
|
||||
common_log(LOG_ERR, "Could not send user registration email for user id=={$user->id}: {$e->getMessage()}");
|
||||
if (!$accept_email_fail) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Welcome message
|
||||
|
34
lib/emailexception.php
Normal file
34
lib/emailexception.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Class for an exception when there is something wrong with sending email
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2016 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class EmailException extends Exception
|
||||
{
|
||||
}
|
@ -524,7 +524,7 @@ abstract class Installer
|
||||
$data['email'] = $this->adminEmail;
|
||||
}
|
||||
try {
|
||||
$user = User::register($data);
|
||||
$user = User::register($data, true); // true to skip email sending verification
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ function mail_backend()
|
||||
$backend = $mail->factory(common_config('mail', 'backend'),
|
||||
common_config('mail', 'params') ?: array());
|
||||
if ($_PEAR->isError($backend)) {
|
||||
throw new ServerException($backend->getMessage());
|
||||
throw new EmailException($backend->getMessage(), $backend->getCode());
|
||||
}
|
||||
}
|
||||
return $backend;
|
||||
@ -82,7 +82,7 @@ function mail_send($recipients, $headers, $body)
|
||||
assert($backend); // throws an error if it's bad
|
||||
$sent = $backend->send($recipients, $headers, $body);
|
||||
if ($_PEAR->isError($sent)) {
|
||||
throw new ServerException($sent->getMessage());
|
||||
throw new EmailException($sent->getMessage(), $sent->getCode());
|
||||
}
|
||||
return true;
|
||||
} catch (PEAR_Exception $e) {
|
||||
|
Loading…
Reference in New Issue
Block a user