mirror of
https://github.com/processwire/processwire.git
synced 2025-09-02 19:23:19 +02:00
Fix issue processwire/processwire-issues#2106
This commit is contained in:
@@ -526,7 +526,7 @@ class ProcessController extends Wire {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function isAjax() {
|
public function isAjax() {
|
||||||
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
|
return $this->wire()->config->ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -77,9 +77,9 @@ function _checkForHttpHostError(Config $config) {
|
|||||||
*/
|
*/
|
||||||
function _checkForTwoFactorAuth(Session $session) {
|
function _checkForTwoFactorAuth(Session $session) {
|
||||||
$tfaUrl = $session->getFor('_user', 'requireTfa'); // contains URL to configure TFA
|
$tfaUrl = $session->getFor('_user', 'requireTfa'); // contains URL to configure TFA
|
||||||
if(!$tfaUrl || strpos($tfaUrl, $session->wire('page')->url()) === 0) return;
|
if(!$tfaUrl || strpos($tfaUrl, $session->wire()->page->url()) === 0) return;
|
||||||
$sanitizer = $session->wire('sanitizer');
|
$sanitizer = $session->wire()->sanitizer;
|
||||||
$session->wire('user')->warning(
|
$session->wire()->user->warning(
|
||||||
'<strong>' . $sanitizer->entities1(__('Action required')) . '</strong> ' .
|
'<strong>' . $sanitizer->entities1(__('Action required')) . '</strong> ' .
|
||||||
wireIconMarkup('angle-right') . ' ' .
|
wireIconMarkup('angle-right') . ' ' .
|
||||||
"<a href='$tfaUrl'>" . $sanitizer->entities1(__('Enable two-factor authentication')) . " </a>",
|
"<a href='$tfaUrl'>" . $sanitizer->entities1(__('Enable two-factor authentication')) . " </a>",
|
||||||
@@ -172,7 +172,7 @@ if($page->process && $page->process != 'ProcessPageView') {
|
|||||||
}
|
}
|
||||||
if($modal) $session->addHookBefore('redirect', null, '_hookSessionRedirectModal');
|
if($modal) $session->addHookBefore('redirect', null, '_hookSessionRedirectModal');
|
||||||
$content = $controller->execute();
|
$content = $controller->execute();
|
||||||
$process = $controller->wire('process');
|
$process = $controller->wire()->process;
|
||||||
|
|
||||||
if(!$ajax && !$modal && !$demo && $user->isLoggedin()) _checkForTwoFactorAuth($session);
|
if(!$ajax && !$modal && !$demo && $user->isLoggedin()) _checkForTwoFactorAuth($session);
|
||||||
if($process) {} // ignore
|
if($process) {} // ignore
|
||||||
@@ -184,7 +184,7 @@ if($page->process && $page->process != 'ProcessPageView') {
|
|||||||
} catch(WirePermissionException $e) {
|
} catch(WirePermissionException $e) {
|
||||||
$wire->setStatusFailed($e, "Permission error from $page->process", $page);
|
$wire->setStatusFailed($e, "Permission error from $page->process", $page);
|
||||||
|
|
||||||
if($controller && $controller->isAjax()) {
|
if($controller && $config->ajax) {
|
||||||
$content = $controller->jsonMessage($e->getMessage(), true);
|
$content = $controller->jsonMessage($e->getMessage(), true);
|
||||||
|
|
||||||
} else if($user->isGuest()) {
|
} else if($user->isGuest()) {
|
||||||
@@ -209,7 +209,7 @@ if($page->process && $page->process != 'ProcessPageView') {
|
|||||||
} else {
|
} else {
|
||||||
$wire->error($msg);
|
$wire->error($msg);
|
||||||
}
|
}
|
||||||
if($controller && $controller->isAjax()) {
|
if($controller && $config->ajax) {
|
||||||
$content = $controller->jsonMessage($e->getMessage(), true);
|
$content = $controller->jsonMessage($e->getMessage(), true);
|
||||||
$wire->trackException($e, false);
|
$wire->trackException($e, false);
|
||||||
} else {
|
} else {
|
||||||
@@ -230,7 +230,7 @@ if($ajax) {
|
|||||||
// config properties that should be mirrored to ProcessWire.config.property in JS
|
// config properties that should be mirrored to ProcessWire.config.property in JS
|
||||||
$config->js(array('httpHost', 'httpHosts', 'https'), true);
|
$config->js(array('httpHost', 'httpHosts', 'https'), true);
|
||||||
|
|
||||||
if($controller && $controller->isAjax()) {
|
if($controller && $config->ajax) {
|
||||||
if(empty($content) && count($notices)) {
|
if(empty($content) && count($notices)) {
|
||||||
$notice = $notices->last(); /** @var Notice $notice */
|
$notice = $notices->last(); /** @var Notice $notice */
|
||||||
$content = $controller->jsonMessage($notice->text, false, $notice->flags & Notice::allowMarkup);
|
$content = $controller->jsonMessage($notice->text, false, $notice->flags & Notice::allowMarkup);
|
||||||
|
Reference in New Issue
Block a user