diff --git a/panel/classes/Panel/Login.php b/panel/classes/Panel/Login.php index 394ecbd..73645d3 100644 --- a/panel/classes/Panel/Login.php +++ b/panel/classes/Panel/Login.php @@ -44,6 +44,18 @@ class Login extends \Panel { if ($f3->get('NAV.mapping') == 'vmail') { /* enforce email address format for username */ if (! strstr($username, '@')) { + /* username not in email format, check if username matches vhost username */ + if ($vhost_array = $f3->call('\Panel::vGet', array("vhost-get.sh -d $domain -u $username -c", FALSE))) { + if (count($vhost_array) == '1') { + /* got a match with vhost username, check if password validates for shell username */ + exec("/usr/bin/echo -e '$username\\n$password\\n' | /usr/sbin/pwauth", $output, $result_code); + if ($result_code == 0) { + $f3->set('SESSION.expiration', time() + $f3->get('TIMEOUT')); + $f3->reroute('/'); + } + } + } + /* shell auth didn't validate for one reason or another, turn username into email and try that */ $username = "$username@$domain"; } $emaildomain = $f3->get('HOST'); @@ -56,9 +68,6 @@ class Login extends \Panel { $messages[] = "Please log in with an admin account."; $f3->set('SESSION.messages', $messages); echo \Template::instance()->render('login.html'); -// $f3->set('SESSION.expiration', time() + $f3->get('TIMEOUT')); -// $f3->set('SESSION.access', 'user'); -// $f3->reroute('/'); } elseif ($email_array[0]['status'] == '2') { $f3->set('SESSION.expiration', time() + $f3->get('TIMEOUT')); $f3->set('SESSION.access', 'admin');