Commit 16ce3afb authored by ergonlogic's avatar ergonlogic

Issue #2038279: Warn of invalid account email on site install.

parent b16aaef6
......@@ -6,4 +6,24 @@
*/
define('PROVISION_DEFAULT_ADMIN_USER', 'admin');
define('PROVISION_DEFAULT_ADMIN_EMAIL', 'admin@example.com');
/**
* Validate client email and throw a helpful error message if it is invalid.
*/
function install_validate_client_email($client_email) {
if (!$client_email || !filter_var($client_email, FILTER_VALIDATE_EMAIL)) {
$invalid_email = 'this.email@is.invalid';
drush_log(t('Error validating client email `!email`. Please check your !user email. To allow the site installation to proceed, the email `!invalid` has been used instead. Please use the `login` link to change the site admin email to a proper valid address.',
array(
'!email' => $client_email,
'!user' => l(t('user account'), 'user'),
'!invalid' => $invalid_email,
)),
'warning'
);
return $invalid_email;
}
else {
return $client_email;
}
}
......@@ -47,19 +47,12 @@ function install_verify_settings() {
return FALSE;
}
function install_create_admin_user($client_email = NULL) {
function install_create_admin_user($client_email) {
$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;
}
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);
......@@ -361,11 +354,7 @@ function install_main() {
cache_clear_all();
variable_set('install_profile', $profile);
$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;
}
$client_email = install_validate_client_email(drush_get_option('client_email', FALSE));
$account = install_create_admin_user($client_email);
$onetime = user_pass_reset_url($account);
......
......@@ -113,11 +113,7 @@ function install_main() {
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;
}
$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;
}
$client_email = install_validate_client_email(drush_get_option('client_email', FALSE));
$settings = array(
'parameters' => array(
'profile' => $profile,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment