diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-09-09 20:25:52 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-09-09 20:25:52 +0200 |
commit | 96f59c6150916fe67723c64f325d9de99fed59fa (patch) | |
tree | 274783c39e0b06ff4fd0627790db6c4b9346bcf5 /program/include | |
parent | ad003c889b27d8bb52c97cf1a087da64f67d4924 (diff) |
Add option force specified domain in user login - username_domain_forced (#1489264)
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/rcmail.php | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 02287d312..0483f0e18 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -481,15 +481,22 @@ class rcmail extends rcube $port = $config['default_port']; } - /* Modify username with domain if required - Inspired by Marco <P0L0_notspam_binware.org> - */ - // Check if we need to add domain - if (!empty($config['username_domain']) && strpos($username, '@') === false) { - if (is_array($config['username_domain']) && isset($config['username_domain'][$host])) - $username .= '@'.rcube_utils::parse_host($config['username_domain'][$host], $host); - else if (is_string($config['username_domain'])) - $username .= '@'.rcube_utils::parse_host($config['username_domain'], $host); + // Check if we need to add/force domain to username + if (!empty($config['username_domain'])) { + $domain = is_array($config['username_domain']) ? $config['username_domain'][$host] : $config['username_domain']; + + if ($domain = rcube_utils::parse_host((string)$domain, $host)) { + $pos = strpos($username, '@'); + + // force configured domains + 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'])) { |