Add option force specified domain in user login - username_domain_forced (#1489264)

pull/121/head
Aleksander Machniak 11 years ago
parent ad003c889b
commit 96f59c6150

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail CHANGELOG Roundcube Webmail
=========================== ===========================
- Add option force specified domain in user login - username_domain_forced (#1489264)
- Fix issue where From address was removed from Cc and Bcc fields when editing a draft (#1489319) - Fix issue where From address was removed from Cc and Bcc fields when editing a draft (#1489319)
- Add option to import Vcards with group assignments - Add option to import Vcards with group assignments
- Save groups membership in Vcard export (#1488509) - Save groups membership in Vcard export (#1488509)

@ -346,6 +346,10 @@ $config['des_key'] = 'rcmail-!24ByteDESkey*Str';
// For example %n = mail.domain.tld, %t = domain.tld // For example %n = mail.domain.tld, %t = domain.tld
$config['username_domain'] = ''; $config['username_domain'] = '';
// Force domain configured in username_domain to be used for login.
// Any domain in username will be replaced by username_domain.
$config['username_domain_forced'] = false;
// This domain will be used to form e-mail addresses of new users // This domain will be used to form e-mail addresses of new users
// Specify an array with 'host' => 'domain' values to support multiple hosts // Specify an array with 'host' => 'domain' values to support multiple hosts
// Supported replacement variables: // Supported replacement variables:

@ -481,15 +481,22 @@ class rcmail extends rcube
$port = $config['default_port']; $port = $config['default_port'];
} }
/* Modify username with domain if required // Check if we need to add/force domain to username
Inspired by Marco <P0L0_notspam_binware.org> if (!empty($config['username_domain'])) {
*/ $domain = is_array($config['username_domain']) ? $config['username_domain'][$host] : $config['username_domain'];
// Check if we need to add domain
if (!empty($config['username_domain']) && strpos($username, '@') === false) { if ($domain = rcube_utils::parse_host((string)$domain, $host)) {
if (is_array($config['username_domain']) && isset($config['username_domain'][$host])) $pos = strpos($username, '@');
$username .= '@'.rcube_utils::parse_host($config['username_domain'][$host], $host);
else if (is_string($config['username_domain'])) // force configured domains
$username .= '@'.rcube_utils::parse_host($config['username_domain'], $host); if (!empty($config['username_domain_forced']) && $pos !== false) {
$username = substr($username, 0, $pos) . '@' . $domain;
}
// just add domain if not specified
else if ($pos === false) {
$username .= '@' . $domain;
}
}
} }
if (!isset($config['login_lc'])) { if (!isset($config['login_lc'])) {

Loading…
Cancel
Save