2017-03-02 11:23:23 +01:00
|
|
|
<?php
|
|
|
|
if (isset($_POST["verify_tfa_login"])) {
|
|
|
|
if (verify_tfa_login($_SESSION['pending_mailcow_cc_username'], $_POST["token"])) {
|
|
|
|
$_SESSION['mailcow_cc_username'] = $_SESSION['pending_mailcow_cc_username'];
|
|
|
|
$_SESSION['mailcow_cc_role'] = $_SESSION['pending_mailcow_cc_role'];
|
|
|
|
unset($_SESSION['pending_mailcow_cc_username']);
|
|
|
|
unset($_SESSION['pending_mailcow_cc_role']);
|
|
|
|
unset($_SESSION['pending_tfa_method']);
|
|
|
|
header("Location: /user.php");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_POST["login_user"]) && isset($_POST["pass_user"])) {
|
|
|
|
$login_user = strtolower(trim($_POST["login_user"]));
|
|
|
|
$as = check_login($login_user, $_POST["pass_user"]);
|
|
|
|
if ($as == "admin") {
|
|
|
|
$_SESSION['mailcow_cc_username'] = $login_user;
|
|
|
|
$_SESSION['mailcow_cc_role'] = "admin";
|
|
|
|
header("Location: /admin.php");
|
|
|
|
}
|
|
|
|
elseif ($as == "domainadmin") {
|
|
|
|
$_SESSION['mailcow_cc_username'] = $login_user;
|
|
|
|
$_SESSION['mailcow_cc_role'] = "domainadmin";
|
|
|
|
header("Location: /mailbox.php");
|
|
|
|
}
|
|
|
|
elseif ($as == "user") {
|
|
|
|
$_SESSION['mailcow_cc_username'] = $login_user;
|
|
|
|
$_SESSION['mailcow_cc_role'] = "user";
|
|
|
|
header("Location: /user.php");
|
|
|
|
}
|
|
|
|
elseif ($as != "pending") {
|
|
|
|
unset($_SESSION['pending_mailcow_cc_username']);
|
|
|
|
unset($_SESSION['pending_mailcow_cc_role']);
|
|
|
|
unset($_SESSION['pending_tfa_method']);
|
|
|
|
unset($_SESSION['mailcow_cc_username']);
|
|
|
|
unset($_SESSION['mailcow_cc_role']);
|
|
|
|
$_SESSION['return'] = array(
|
|
|
|
'type' => 'danger',
|
|
|
|
'msg' => $lang['danger']['login_failed']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admin") {
|
|
|
|
if (isset($_GET["duallogin"])) {
|
|
|
|
if (filter_var($_GET["duallogin"], FILTER_VALIDATE_EMAIL)) {
|
2017-05-23 09:36:59 +02:00
|
|
|
if (!empty(mailbox('get', 'mailbox_details', $_GET["duallogin"]))) {
|
2017-03-02 11:23:23 +01:00
|
|
|
$_SESSION["dual-login"]["username"] = $_SESSION['mailcow_cc_username'];
|
|
|
|
$_SESSION["dual-login"]["role"] = $_SESSION['mailcow_cc_role'];
|
|
|
|
$_SESSION['mailcow_cc_username'] = $_GET["duallogin"];
|
|
|
|
$_SESSION['mailcow_cc_role'] = "user";
|
|
|
|
header("Location: /user.php");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 10:32:17 +02:00
|
|
|
|
2017-03-02 11:23:23 +01:00
|
|
|
if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "admin" || $_SESSION['mailcow_cc_role'] == "domainadmin")) {
|
|
|
|
if (isset($_POST["set_tfa"])) {
|
|
|
|
set_tfa($_POST);
|
|
|
|
}
|
|
|
|
if (isset($_POST["unset_tfa_key"])) {
|
|
|
|
unset_tfa_key($_POST);
|
|
|
|
}
|
|
|
|
}
|
2017-10-21 10:07:06 +02:00
|
|
|
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admin") {
|
2017-12-09 13:17:15 +01:00
|
|
|
// TODO: Move file upload to API?
|
2017-10-21 10:07:06 +02:00
|
|
|
if (isset($_POST["submit_main_logo"])) {
|
|
|
|
if ($_FILES['main_logo']['error'] == 0) {
|
|
|
|
customize('add', 'main_logo', $_FILES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($_POST["reset_main_logo"])) {
|
|
|
|
customize('delete', 'main_logo');
|
|
|
|
}
|
2017-12-09 13:17:15 +01:00
|
|
|
// API cannot be controlled by API
|
|
|
|
if (isset($_POST["admin_api"])) {
|
|
|
|
admin_api('edit', $_POST);
|
|
|
|
}
|
|
|
|
if (isset($_POST["admin_api_regen_key"])) {
|
|
|
|
admin_api('regen_key', $_POST);
|
|
|
|
}
|
|
|
|
// Not available via API
|
|
|
|
if (isset($_POST["rspamd_ui"])) {
|
|
|
|
rspamd_ui('edit', $_POST);
|
|
|
|
}
|
2017-10-21 10:07:06 +02:00
|
|
|
}
|
2017-03-02 11:23:23 +01:00
|
|
|
?>
|