Improved login default_domain with dynamic options

This commit is contained in:
the-djmaze 2022-10-27 12:31:09 +02:00
parent f3e6dda69b
commit ba4b8f84cc
2 changed files with 11 additions and 1 deletions

View file

@ -86,6 +86,11 @@ trait UserAuth
if (!\str_contains($sEmail, '@')) {
$sDefDomain = \trim($this->Config()->Get('login', 'default_domain', ''));
if (\strlen($sDefDomain)) {
if ('HTTP_HOST' === $sDefDomain || 'SERVER_NAME' === $sDefDomain) {
$sDefDomain = \preg_replace('/:[0-9]+$/D', '', $_SERVER[$sDefDomain]);
} else if ('gethostname' === $sDefDomain) {
$sDefDomain = \gethostname();
}
$this->Logger()->Write('Default domain "' . $sDefDomain . '" was used. (' . $sEmail . ' > ' . $sEmail . '@' . $sDefDomain . ')',
\LOG_INFO, 'LOGIN');

View file

@ -225,7 +225,12 @@ class Application extends \RainLoop\Config\AbstractConfig
'login' => array(
'default_domain' => array(''),
'default_domain' => array('',
'If someone logs in without "@domain.tld", this value will be used
When this value is HTTP_HOST, the $_SERVER["HTTP_HOST"] value is used.
When this value is SERVER_NAME, the $_SERVER["SERVER_NAME"] value is used.
When this value is gethostname, the gethostname() value is used.
'),
'allow_languages_on_login' => array(true,
'Allow language selection on webmail login screen'),