summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Gervais2013-07-16 18:02:01 (GMT)
committerChristopher Gervais2013-07-16 18:02:01 (GMT)
commit77cbe7d769c7e8c436ae8cff7399c53b7b3a3f94 (patch)
tree921a4e05dcbf6d4a2a28352b40d72b7f03574358
parent58e57ecc87f4fd028e16741c3a3e09f984e5e845 (diff)
Issue #2038279 by ergonlogic, Jon Pugh: Validate email during site install.
-rw-r--r--platform/drupal/install.inc1
-rw-r--r--platform/drupal/install_6.inc18
-rw-r--r--platform/drupal/install_7.inc15
3 files changed, 24 insertions, 10 deletions
diff --git a/platform/drupal/install.inc b/platform/drupal/install.inc
index b1bcc8c..565885f 100644
--- a/platform/drupal/install.inc
+++ b/platform/drupal/install.inc
@@ -6,3 +6,4 @@
*/
define('PROVISION_DEFAULT_ADMIN_USER', 'admin');
+define('PROVISION_DEFAULT_ADMIN_EMAIL', 'admin@example.com');
diff --git a/platform/drupal/install_6.inc b/platform/drupal/install_6.inc
index 00c88cf..f61b57b 100644
--- a/platform/drupal/install_6.inc
+++ b/platform/drupal/install_6.inc
@@ -50,12 +50,17 @@ function install_verify_settings() {
function install_create_admin_user($client_email = NULL) {
$name = drush_get_option('admin_user', PROVISION_DEFAULT_ADMIN_USER);
if ($error = user_validate_name($name)) {
+ drush_log(dt('Error setting UID username to `!user`: ', array('!user' => $name)) . $error . dt(' Using default (!default) instead.', array('!default' => PROVISION_DEFAULT_ADMIN_USER)), 'warning');
$name = PROVISION_DEFAULT_ADMIN_USER;
- drush_log(dt('Error setting UID username to `!user`: ', array('!user' => $name)) . $error . dt(' Using default (!default) instead.', array('!default' => $name)), 'warning');
}
- if (!$client_email) {
- $client_email = 'webmaster@localhost';
+ if (!isset($client_email)) {
+ $client_email = drush_get_option('client_email', PROVISION_DEFAULT_ADMIN_EMAIL);
+ if (!filter_var($client_email, FILTER_VALIDATE_EMAIL)) {
+ drush_log(dt('Error validating client email `!email`. Please check your user account email. Using default (!default) instead.', array('!email' => $client_email, '!default' => PROVISION_DEFAULT_ADMIN_EMAIL)) , 'warning');
+ $client_email = PROVISION_DEFAULT_ADMIN_EMAIL;
+ }
}
+
// create the admin account
$account = user_load(1);
$edit['name'] = $name;
@@ -356,7 +361,12 @@ function install_main() {
cache_clear_all();
variable_set('install_profile', $profile);
- $client_email = drush_get_option('client_email');
+ $client_email = drush_get_option('client_email', PROVISION_DEFAULT_ADMIN_EMAIL);
+ if (!filter_var($client_email, FILTER_VALIDATE_EMAIL)) {
+ drush_log(dt('Error validating client email `!email`. Please check your user account email. Using default (!default) instead.', array('!email' => $client_email, '!default' => PROVISION_DEFAULT_ADMIN_EMAIL)) , 'warning');
+ $client_email = PROVISION_DEFAULT_ADMIN_EMAIL;
+ }
+
$account = install_create_admin_user($client_email);
$onetime = user_pass_reset_url($account);
// Store the one time login link in an option so the front end can direct the user to their new site.
diff --git a/platform/drupal/install_7.inc b/platform/drupal/install_7.inc
index 7f7ecbc..54bed3f 100644
--- a/platform/drupal/install_7.inc
+++ b/platform/drupal/install_7.inc
@@ -74,8 +74,6 @@ function install_mail($key, &$message, $params) {
function install_main() {
global $profile, $install_locale, $conf, $url, $base_url;
- $client_email = drush_get_option('client_email');
-
require_once DRUPAL_ROOT . '/includes/install.core.inc';
require_once DRUPAL_ROOT . '/includes/entity.inc';
require_once DRUPAL_ROOT . '/includes/unicode.inc';
@@ -112,8 +110,13 @@ function install_main() {
$account_pass = provision_password();
$name = drush_get_option('admin_user', PROVISION_DEFAULT_ADMIN_USER);
if ($error = user_validate_name($name)) {
+ drush_log(dt('Error setting UID username to `!user`: ', array('!user' => $name)) . $error . dt(' Using default (!default) instead.', array('!default' => PROVISION_DEFAULT_ADMIN_USER)) , 'warning');
$name = PROVISION_DEFAULT_ADMIN_USER;
- drush_log(dt('Error setting UID username to `!user`: ', array('!user' => $name)) . $error . dt(' Using default (!default) instead.', array('!default' => $name)) , 'warning');
+ }
+ $client_email = drush_get_option('client_email', PROVISION_DEFAULT_ADMIN_EMAIL);
+ if (!filter_var($client_email, FILTER_VALIDATE_EMAIL)) {
+ drush_log(dt('Error validating client email `!email`. Please check your user account email. Using default (!default) instead.', array('!email' => $client_email, '!default' => PROVISION_DEFAULT_ADMIN_EMAIL)) , 'warning');
+ $client_email = PROVISION_DEFAULT_ADMIN_EMAIL;
}
$settings = array(
'parameters' => array(
@@ -125,10 +128,10 @@ function install_main() {
'install_settings_form' => $db_spec,
'install_configure_form' => array(
'site_name' => $url,
- 'site_mail' => $client_email ? $client_email : 'admin@example.com',
+ 'site_mail' => $client_email,
'account' => array(
'name' => $name,
- 'mail' => $client_email ? $client_email : 'admin@example.com',
+ 'mail' => $client_email,
'pass' => array(
'pass1' => $account_pass,
'pass2' => $account_pass,
@@ -169,7 +172,7 @@ function install_main() {
drush_set_option('login_link', $onetime . '/login');
drush_log(t('Login url: !onetime', array('!onetime' => $onetime . '/login')), 'success');
- if ($client_email) {
+ if (drush_get_option('client_email', FALSE)) {
install_send_welcome_mail($url, $account, $install_locale, $client_email, $onetime);
}
}