Mail bugfix, gpg, profile frontend WIP
This commit is contained in:
@@ -55,14 +55,15 @@ namespace Core\API\Mail {
|
||||
use Core\External\PHPMailer\PHPMailer;
|
||||
use Core\Objects\Context;
|
||||
use Core\Objects\DatabaseEntity\GpgKey;
|
||||
use PhpParser\Node\Param;
|
||||
|
||||
class Test extends MailAPI {
|
||||
|
||||
public function __construct(Context $context, bool $externalCall = false) {
|
||||
parent::__construct($context, $externalCall, array(
|
||||
parent::__construct($context, $externalCall, [
|
||||
"receiver" => new Parameter("receiver", Parameter::TYPE_EMAIL),
|
||||
"gpgFingerprint" => new StringType("gpgFingerprint", 64, true, null)
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
@@ -74,10 +75,12 @@ namespace Core\API\Mail {
|
||||
"subject" => "Test E-Mail",
|
||||
"body" => "Hey! If you receive this e-mail, your mail configuration seems to be working.",
|
||||
"gpgFingerprint" => $this->getParam("gpgFingerprint"),
|
||||
"async" => false
|
||||
"async" => false,
|
||||
"debug" => true,
|
||||
));
|
||||
|
||||
$this->lastError = $req->getLastError();
|
||||
$this->result["output"] = $req->getResult()["output"];
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
@@ -95,7 +98,8 @@ namespace Core\API\Mail {
|
||||
'replyTo' => new Parameter('replyTo', Parameter::TYPE_EMAIL, true, null),
|
||||
'replyName' => new StringType('replyName', 32, true, ""),
|
||||
'gpgFingerprint' => new StringType("gpgFingerprint", 64, true, null),
|
||||
'async' => new Parameter("async", Parameter::TYPE_BOOLEAN, true, null)
|
||||
'async' => new Parameter("async", Parameter::TYPE_BOOLEAN, true, null),
|
||||
'debug' => new Parameter("debug", Parameter::TYPE_BOOLEAN, true, false)
|
||||
));
|
||||
$this->isPublic = false;
|
||||
}
|
||||
@@ -115,6 +119,7 @@ namespace Core\API\Mail {
|
||||
$replyName = $this->getParam('replyName');
|
||||
$body = $this->getParam('body');
|
||||
$gpgFingerprint = $this->getParam("gpgFingerprint");
|
||||
$debug = $this->getParam("debug");
|
||||
|
||||
$mailAsync = $this->getParam("async");
|
||||
if ($mailAsync === null) {
|
||||
@@ -156,8 +161,9 @@ namespace Core\API\Mail {
|
||||
$mail->addReplyTo($replyTo, $replyName);
|
||||
}
|
||||
|
||||
|
||||
$mail->Subject = $subject;
|
||||
$mail->SMTPDebug = 0;
|
||||
$mail->SMTPDebug = $debug ? 2 : 0;
|
||||
$mail->Host = $mailConfig->getHost();
|
||||
$mail->Port = $mailConfig->getPort();
|
||||
$mail->SMTPAuth = true;
|
||||
@@ -193,12 +199,22 @@ namespace Core\API\Mail {
|
||||
$mail->AltBody = strip_tags($body);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$this->success = @$mail->Send();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
if (!$this->success) {
|
||||
$this->lastError = "Error sending Mail: $mail->ErrorInfo";
|
||||
$this->logger->error("sendMail() failed: $mail->ErrorInfo");
|
||||
if ($debug) {
|
||||
$this->logger->debug($output);
|
||||
$this->result["output"] = $output;
|
||||
}
|
||||
} else {
|
||||
$this->result["messageId"] = $mail->getLastMessageID();
|
||||
if ($debug) {
|
||||
$this->result["output"] = $output;
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->success = false;
|
||||
|
||||
@@ -1240,9 +1240,9 @@ namespace Core\API\User {
|
||||
class ImportGPG extends UserAPI {
|
||||
|
||||
public function __construct(Context $context, bool $externalCall = false) {
|
||||
parent::__construct($context, $externalCall, array(
|
||||
parent::__construct($context, $externalCall, [
|
||||
"pubkey" => new StringType("pubkey")
|
||||
));
|
||||
]);
|
||||
$this->loginRequired = true;
|
||||
$this->forbidMethod("GET");
|
||||
}
|
||||
@@ -1342,6 +1342,10 @@ namespace Core\API\User {
|
||||
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to import gpg keys for a secure e-mail communication", true);
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveGPG extends UserAPI {
|
||||
@@ -1371,6 +1375,10 @@ namespace Core\API\User {
|
||||
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public static function getDefaultACL(Insert $insert): void {
|
||||
$insert->addRow(self::getEndpoint(), [], "Allows users to unlink gpg keys from their profile", true);
|
||||
}
|
||||
}
|
||||
|
||||
class ConfirmGPG extends UserAPI {
|
||||
|
||||
@@ -85,4 +85,15 @@ return [
|
||||
"remove_group_member_text" => "Möchten Sie wirklich den Benutzer '%s' von dieser Gruppe entfernen?",
|
||||
"add_group_member_title" => "Mitglied hinzufügen",
|
||||
"add_group_member_text" => "Einen Benutzer suchen um ihn der Gruppe hinzuzufügen",
|
||||
|
||||
# GPG Key
|
||||
"gpg_key_placeholder_text" => "GPG-Key im ASCII format reinziehen oder einfügen...",
|
||||
|
||||
# 2fa
|
||||
"register_2fa_device" => "Ein 2FA-Gerät registrieren",
|
||||
"register_2fa_totp_text" => "Scan den QR-Code mit einem Gerät, das du als Zwei-Faktor-Authentifizierung (2FA) benutzen willst. " .
|
||||
"Unter Android kannst du den Google Authenticator benutzen.",
|
||||
"register_2fa_fido_text" => "Möglicherweise musst du mit dem Gerät interagieren, zum Beispiel durch Eingeben einer PIN oder durch Berühren des Geräts",
|
||||
"remove_2fa" => "2FA-Token entfernen",
|
||||
"remove_2fa_text" => "Gib dein aktuelles Passwort ein um das Entfernen des 2FA-Tokens zu bestätigen",
|
||||
];
|
||||
@@ -34,6 +34,7 @@ return [
|
||||
"yes" => "Ja",
|
||||
"no" => "Nein",
|
||||
"create_new" => "Erstellen",
|
||||
"unchanged" => "Unverändert",
|
||||
|
||||
# dialog / actions
|
||||
"action" => "Aktion",
|
||||
|
||||
@@ -12,17 +12,6 @@ return [
|
||||
"show_only_active_keys" => "Zeige nur aktive Schlüssel",
|
||||
"no_api_key_registered" => "Keine gültigen API-Schlüssel registriert",
|
||||
|
||||
# GPG Key
|
||||
"gpg_key_placeholder_text" => "GPG-Key im ASCII format reinziehen oder einfügen...",
|
||||
|
||||
# 2fa
|
||||
"register_2fa_device" => "Ein 2FA-Gerät registrieren",
|
||||
"register_2fa_totp_text" => "Scan den QR-Code mit einem Gerät, das du als Zwei-Faktor-Authentifizierung (2FA) benutzen willst. " .
|
||||
"Unter Android kannst du den Google Authenticator benutzen.",
|
||||
"register_2fa_fido_text" => "Möglicherweise musst du mit dem Gerät interagieren, zum Beispiel durch Eingeben einer PIN oder durch Berühren des Geräts",
|
||||
"remove_2fa" => "2FA-Token entfernen",
|
||||
"remove_2fa_text" => "Gib dein aktuelles Passwort ein um das Entfernen des 2FA-Tokens zu bestätigen",
|
||||
|
||||
# settings
|
||||
"key" => "Schlüssel",
|
||||
"value" => "Wert",
|
||||
@@ -30,7 +19,6 @@ return [
|
||||
"mail" => "Mail",
|
||||
"recaptcha" => "reCaptcha",
|
||||
"uncategorized" => "Unkategorisiert",
|
||||
"unchanged" => "Unverändert",
|
||||
|
||||
# general settings
|
||||
"site_name" => "Seitenname",
|
||||
|
||||
@@ -85,4 +85,15 @@ return [
|
||||
"remove_group_member_text" => "Do you really want to remove user '%s' from this group?",
|
||||
"add_group_member_title" => "Add member",
|
||||
"add_group_member_text" => "Search a user to add to the group",
|
||||
|
||||
# GPG Key
|
||||
"gpg_key_placeholder_text" => "Paste or drag'n'drop your GPG-Key in ASCII format...",
|
||||
|
||||
# 2fa
|
||||
"register_2fa_device" => "Register a 2FA-Device",
|
||||
"register_2fa_totp_text" => "Scan the QR-Code with a device you want to use for Two-Factor-Authentication (2FA). " .
|
||||
"On Android, you can use the Google Authenticator.",
|
||||
"register_2fa_fido_text" => "You may need to interact with your Device, e.g. typing in your PIN or touching to confirm the registration.",
|
||||
"remove_2fa" => "Remove 2FA Token",
|
||||
"remove_2fa_text" => "Enter your current password to confirm the removal of your 2FA Token",
|
||||
];
|
||||
@@ -16,6 +16,7 @@ return [
|
||||
"yes" => "Yes",
|
||||
"no" => "No",
|
||||
"create_new" => "Create",
|
||||
"unchanged" => "Unchanged",
|
||||
|
||||
# dialog / actions
|
||||
"action" => "Action",
|
||||
|
||||
@@ -12,17 +12,6 @@ return [
|
||||
"show_only_active_keys" => "Show only active keys",
|
||||
"no_api_key_registered" => "No valid API-Keys registered",
|
||||
|
||||
# GPG Key
|
||||
"gpg_key_placeholder_text" => "Paste or drag'n'drop your GPG-Key in ASCII format...",
|
||||
|
||||
# 2fa
|
||||
"register_2fa_device" => "Register a 2FA-Device",
|
||||
"register_2fa_totp_text" => "Scan the QR-Code with a device you want to use for Two-Factor-Authentication (2FA). " .
|
||||
"On Android, you can use the Google Authenticator.",
|
||||
"register_2fa_fido_text" => "You may need to interact with your Device, e.g. typing in your PIN or touching to confirm the registration.",
|
||||
"remove_2fa" => "Remove 2FA Token",
|
||||
"remove_2fa_text" => "Enter your current password to confirm the removal of your 2FA Token",
|
||||
|
||||
# settings
|
||||
"key" => "Key",
|
||||
"value" => "Value",
|
||||
@@ -30,7 +19,6 @@ return [
|
||||
"mail" => "Mail",
|
||||
"recaptcha" => "reCaptcha",
|
||||
"uncategorized" => "Uncategorized",
|
||||
"unchanged" => "Unchanged",
|
||||
|
||||
# general settings
|
||||
"site_name" => "Site Name",
|
||||
|
||||
Reference in New Issue
Block a user