diff --git a/include/pages/login.inc.php b/include/pages/login.inc.php
index d58f9213..8d4a05df 100644
--- a/include/pages/login.inc.php
+++ b/include/pages/login.inc.php
@@ -18,28 +18,30 @@ if ($setting->getValue('recaptcha_enabled') && $setting->getValue('recaptcha_ena
}
}
-if ($setting->getValue('maintenance') && !$user->isAdmin($user->getUserIdByEmail($_POST['username']))) {
- $_SESSION['POPUP'][] = array('CONTENT' => 'You are not allowed to login during maintenace.', 'TYPE' => 'info');
-} else if (!empty($_POST['username']) && !empty($_POST['password'])) {
- // Check if recaptcha is enabled, process form data if valid
- if (!$setting->getValue('recaptcha_enabled') || !$setting->getValue('recaptcha_enabled_logins') || ($setting->getValue('recaptcha_enabled') && $setting->getValue('recaptcha_enabled_logins') && $rsp->is_valid)) {
- if (!$config['csrf']['enabled'] || $config['csrf']['enabled'] && $csrftoken->valid) {
- // check if login is correct
- if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) {
- $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
- $location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
- $location .= $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME'];
- $location.= '?page=dashboard';
- if (!headers_sent()) header('Location: ' . $location);
- exit('');
+if (!empty($_POST['username']) && !empty($_POST['password'])) {
+ if ($setting->getValue('maintenance') && !$user->isAdmin($user->getUserIdByEmail($_POST['username']))) {
+ $_SESSION['POPUP'][] = array('CONTENT' => 'You are not allowed to login during maintenace.', 'TYPE' => 'alert alert-info');
+ } else {
+ // Check if recaptcha is enabled, process form data if valid
+ if (!$setting->getValue('recaptcha_enabled') || !$setting->getValue('recaptcha_enabled_logins') || ($setting->getValue('recaptcha_enabled') && $setting->getValue('recaptcha_enabled_logins') && $rsp->is_valid)) {
+ if (!$config['csrf']['enabled'] || $config['csrf']['enabled'] && $csrftoken->valid) {
+ // check if login is correct
+ if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) {
+ $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]);
+ $location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';
+ $location .= $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME'];
+ $location.= '?page=dashboard';
+ if (!headers_sent()) header('Location: ' . $location);
+ exit('');
+ } else {
+ $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to login: '.$user->getError(), 'TYPE' => 'alert alert-danger');
+ }
} else {
- $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to login: '.$user->getError(), 'TYPE' => 'alert alert-danger');
+ $_SESSION['POPUP'][] = array('CONTENT' => $csrftoken->getErrorWithDescriptionHTML(), 'TYPE' => 'alert alert-warning');
}
} else {
- $_SESSION['POPUP'][] = array('CONTENT' => $csrftoken->getErrorWithDescriptionHTML(), 'TYPE' => 'alert alert-warning');
+ $_SESSION['POPUP'][] = array('CONTENT' => 'Invalid Captcha, please try again.', 'TYPE' => 'alert alert-danger');
}
- } else {
- $_SESSION['POPUP'][] = array('CONTENT' => 'Invalid Captcha, please try again.', 'TYPE' => 'alert alert-danger');
}
}
// Load login template