Show error notice when email is sent from unauthorized email

[MAILPOET-1787]
This commit is contained in:
Ján Mikláš
2019-02-19 16:45:47 +01:00
committed by M. Shull
parent 79bd178123
commit f5feb032fe
8 changed files with 56 additions and 10 deletions

View File

@ -73,6 +73,7 @@ class Menu {
$this->subscribers_over_limit = $subscribers_feature->check();
$this->checkMailPoetAPIKey();
$this->checkPremiumKey();
$this->checkFromEmailAuthorization();
add_action(
'admin_menu',
@ -836,6 +837,13 @@ class Menu {
$this->premium_key_valid = $checker->isPremiumKeyValid($show_notices);
}
function checkFromEmailAuthorization(ServicesChecker $checker = null) {
if (self::isOnMailPoetAdminPage()) {
$checker = $checker ?: new ServicesChecker();
$checker->isFromEmailAuthorized(true);
}
}
function getLimitPerPage($model = null) {
if ($model === null) {
return Listing\Handler::DEFAULT_LIMIT_PER_PAGE;

View File

@ -1,6 +1,7 @@
<?php
namespace MailPoet\Config;
use MailPoet\Mailer\MailerError;
use MailPoet\Models\Subscriber;
use MailPoet\Services\Bridge;
use MailPoet\Settings\SettingsController;
@ -115,4 +116,17 @@ class ServicesChecker {
return false;
}
function isFromEmailAuthorized($display_error_notice = true) {
$mta_log_error = $this->settings->get('mta_log.error', []);
if ($mta_log_error && $mta_log_error['operation'] === MailerError::OPERATION_AUTHORIZATION) {
if ($display_error_notice) {
WPNotice::displayError($mta_log_error['error_message'], 'js-error-unauthorized-email', '', false, false);
}
return false;
}
return true;
}
}