From 61f776173f00c064f2aa3c3cbdf35c1e32357cbe Mon Sep 17 00:00:00 2001 From: andryyy Date: Sun, 15 Dec 2019 13:02:38 +0100 Subject: [PATCH] [Web] Better mobileconfig handling --- data/web/inc/triggers.inc.php | 10 ++++++++++ data/web/index.php | 10 +++++++++- data/web/lang/lang.de.json | 7 +++++++ data/web/lang/lang.en.json | 7 +++++++ data/web/mailbox.php | 14 ++++++++------ data/web/mobileconfig.php | 7 +++++-- data/web/user.php | 10 ++++++++++ 7 files changed, 56 insertions(+), 9 deletions(-) diff --git a/data/web/inc/triggers.inc.php b/data/web/inc/triggers.inc.php index ce943be1..03f64f91 100644 --- a/data/web/inc/triggers.inc.php +++ b/data/web/inc/triggers.inc.php @@ -37,6 +37,16 @@ if (isset($_POST["login_user"]) && isset($_POST["pass_user"])) { $_SESSION['mailcow_cc_username'] = $login_user; $_SESSION['mailcow_cc_role'] = "user"; $_SESSION['mailcow_cc_last_login'] = last_login($login_user); + $http_parameters = explode('&', $_SESSION['index_query_string']); + unset($_SESSION['index_query_string']); + if (in_array('mobileconfig', $http_parameters)) { + if (in_array('only_email', $http_parameters)) { + header("Location: /mobileconfig.php?email_only"); + die(); + } + header("Location: /mobileconfig.php"); + die(); + } header("Location: /user"); } elseif ($as != "pending") { diff --git a/data/web/index.php b/data/web/index.php index c9eb6b3f..b8e53a87 100644 --- a/data/web/index.php +++ b/data/web/index.php @@ -22,6 +22,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == ' require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php'; $_SESSION['return_to'] = $_SERVER['REQUEST_URI']; +$_SESSION['index_query_string'] = $_SERVER['QUERY_STRING']; ?>
@@ -32,12 +33,19 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
+ +
+
- +
diff --git a/data/web/lang/lang.de.json b/data/web/lang/lang.de.json index 1b42a262..d5ea4e87 100644 --- a/data/web/lang/lang.de.json +++ b/data/web/lang/lang.de.json @@ -217,6 +217,11 @@ }, "user": { "generate": "generieren", + "apple_connection_profile": "Apple Verbindungsprofil", + "apple_connection_profile_mailonly": "Dieses Verbindungsprofil beinhaltet IMAP und SMTP Konfigurationen für ein Apple Gerät.", + "apple_connection_profile_complete": "Dieses Verbindungsprofil beinhaltet neben IMAP und SMTP Konfigurationen auch Pfade für die Konfiguration von CalDAV (Kalender) und CardDAV (Adressbücher) für ein Apple Gerät.", + "email": "E-Mail", + "email_and_dav": "E-Mail, Kalender und Adressbücher", "create_app_passwd": "Erstelle App Passwort", "app_passwds": "App Passwörter", "app_name": "App Name", @@ -566,6 +571,7 @@ "booking_0_short": "Immer verfügbar", "booking_lt0_short": "Weiches Limit", "booking_custom_short": "Hartes Limit", + "alias_domain_alias_hint": "Alias-Adressen werden nicht automatisch auch auf Domain-Alias Adressen angewendet. Eine Alias-Adresse mein-alias@domain bildet demnach nicht die Adresse my-alias@alias-domain ab.", "domain": "Domain", "spam_aliases": "Temp. Alias", "alias": "Alias", @@ -848,6 +854,7 @@ "username": "Benutzername", "password": "Passwort", "login": "Anmelden", + "mobileconfig_info": "Bitte als Mailbox-Benutzer einloggen, um das Verbindungsprofil herunterzuladen.", "delayed": "Login wurde zur Sicherheit um %s Sekunde/n verzögert." }, "tfa": { diff --git a/data/web/lang/lang.en.json b/data/web/lang/lang.en.json index d8dcb428..a7073bde 100644 --- a/data/web/lang/lang.en.json +++ b/data/web/lang/lang.en.json @@ -216,6 +216,11 @@ "ip_invalid": "Skipped invalid IP: %s" }, "user": { + "apple_connection_profile": "Apple connection profile", + "apple_connection_profile_mailonly": "This connection profile includes IMAP and SMTP configuration parameters for an Apple device.", + "apple_connection_profile_complete": "This connection profile includes IMAP and SMTP parameters as well as CalDAV (calendars) and CardDAV (contacts) pathes for an Apple device.", + "email": "Email", + "email_and_dav": "Email, calendars and contacts", "generate": "generate", "create_app_passwd": "Create app password", "app_passwds": "App passwords", @@ -565,6 +570,7 @@ "booking_0_short": "Always free", "booking_lt0_short": "Soft limit", "booking_custom_short": "Hard limit", + "alias_domain_alias_hint": "Aliases are not applied on domain aliases automatically. An alias address my-alias@domain does not cover the address my-alias@alias-domain (where \"alias-domain\" is an imaginary alias domain for \"domain\").", "domain": "Domain", "spam_aliases": "Temp. alias", "multiple_bookings": "Multiple bookings", @@ -847,6 +853,7 @@ "username": "Username", "password": "Password", "login": "Login", + "mobileconfig_info": "Please login as mailbox user to download the requested Apple connection profile.", "delayed": "Login was delayed by %s seconds." }, "tfa": { diff --git a/data/web/mailbox.php b/data/web/mailbox.php index bf9e3d9c..78d38c92 100644 --- a/data/web/mailbox.php +++ b/data/web/mailbox.php @@ -108,6 +108,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
+
+

-

+

-

+

-

+
@@ -124,12 +129,6 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
-
-

-

-

-

-

-

-
@@ -168,6 +167,9 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI']; +
+ +
diff --git a/data/web/mobileconfig.php b/data/web/mobileconfig.php index 38b249c6..bc4de03d 100644 --- a/data/web/mobileconfig.php +++ b/data/web/mobileconfig.php @@ -5,8 +5,11 @@ if (empty($mailcow_hostname)) { exit(); } if (!isset($_SESSION['mailcow_cc_role']) || $_SESSION['mailcow_cc_role'] != 'user') { - header("Location: index.php"); - die("This page is only available to logged-in users, not admins."); + session_destroy(); + // probably better than appending the whole current http query string + $append_get = (isset($_GET['only_email'])) ? '&only_email' : ''; + header('Location: index.php?mobileconfig' . $append_get); + die(); } error_reporting(0); diff --git a/data/web/user.php b/data/web/user.php index 9081670d..ad24811f 100644 --- a/data/web/user.php +++ b/data/web/user.php @@ -130,6 +130,16 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
+
+
:
+
+

IMAP, SMTP

+

+

IMAP, SMTP, Cal/CardDAV

+

+
+
+