|
18 | 18 | } |
19 | 19 | } |
20 | 20 |
|
21 | | -if ($setting->getValue('maintenance') && !$user->isAdmin($user->getUserIdByEmail($_POST['username']))) { |
22 | | - $_SESSION['POPUP'][] = array('CONTENT' => 'You are not allowed to login during maintenace.', 'TYPE' => 'info'); |
23 | | -} else if (!empty($_POST['username']) && !empty($_POST['password'])) { |
24 | | - // Check if recaptcha is enabled, process form data if valid |
25 | | - if (!$setting->getValue('recaptcha_enabled') || !$setting->getValue('recaptcha_enabled_logins') || ($setting->getValue('recaptcha_enabled') && $setting->getValue('recaptcha_enabled_logins') && $rsp->is_valid)) { |
26 | | - if (!$config['csrf']['enabled'] || $config['csrf']['enabled'] && $csrftoken->valid) { |
27 | | - // check if login is correct |
28 | | - if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) { |
29 | | - $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); |
30 | | - $location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://'; |
31 | | - $location .= $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME']; |
32 | | - $location.= '?page=dashboard'; |
33 | | - if (!headers_sent()) header('Location: ' . $location); |
34 | | - exit('<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($location) . '"/>'); |
| 21 | +if (!empty($_POST['username']) && !empty($_POST['password'])) { |
| 22 | + if ($setting->getValue('maintenance') && !$user->isAdmin($user->getUserIdByEmail($_POST['username']))) { |
| 23 | + $_SESSION['POPUP'][] = array('CONTENT' => 'You are not allowed to login during maintenace.', 'TYPE' => 'alert alert-info'); |
| 24 | + } else { |
| 25 | + // Check if recaptcha is enabled, process form data if valid |
| 26 | + if (!$setting->getValue('recaptcha_enabled') || !$setting->getValue('recaptcha_enabled_logins') || ($setting->getValue('recaptcha_enabled') && $setting->getValue('recaptcha_enabled_logins') && $rsp->is_valid)) { |
| 27 | + if (!$config['csrf']['enabled'] || $config['csrf']['enabled'] && $csrftoken->valid) { |
| 28 | + // check if login is correct |
| 29 | + if ($user->checkLogin(@$_POST['username'], @$_POST['password']) ) { |
| 30 | + $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); |
| 31 | + $location = (@$_SERVER['HTTPS'] == "on") ? 'https://' : 'http://'; |
| 32 | + $location .= $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME']; |
| 33 | + $location.= '?page=dashboard'; |
| 34 | + if (!headers_sent()) header('Location: ' . $location); |
| 35 | + exit('<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($location) . '"/>'); |
| 36 | + } else { |
| 37 | + $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to login: '.$user->getError(), 'TYPE' => 'alert alert-danger'); |
| 38 | + } |
35 | 39 | } else { |
36 | | - $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to login: '.$user->getError(), 'TYPE' => 'alert alert-danger'); |
| 40 | + $_SESSION['POPUP'][] = array('CONTENT' => $csrftoken->getErrorWithDescriptionHTML(), 'TYPE' => 'alert alert-warning'); |
37 | 41 | } |
38 | 42 | } else { |
39 | | - $_SESSION['POPUP'][] = array('CONTENT' => $csrftoken->getErrorWithDescriptionHTML(), 'TYPE' => 'alert alert-warning'); |
| 43 | + $_SESSION['POPUP'][] = array('CONTENT' => 'Invalid Captcha, please try again.', 'TYPE' => 'alert alert-danger'); |
40 | 44 | } |
41 | | - } else { |
42 | | - $_SESSION['POPUP'][] = array('CONTENT' => 'Invalid Captcha, please try again.', 'TYPE' => 'alert alert-danger'); |
43 | 45 | } |
44 | 46 | } |
45 | 47 | // Load login template |
|
0 commit comments