From e1fc82973206532e45fe30525b6a38de1226d196 Mon Sep 17 00:00:00 2001 From: benjamin Date: Thu, 7 Dec 2023 17:17:07 +0000 Subject: [PATCH] standalone access denied: show login form with 403 on page route --- CRM/Utils/System/Standalone.php | 13 ++++++++++--- .../CRM/Standaloneusers/Page/Login.php | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CRM/Utils/System/Standalone.php b/CRM/Utils/System/Standalone.php index 18f5b7bfc7..265d2ef438 100644 --- a/CRM/Utils/System/Standalone.php +++ b/CRM/Utils/System/Standalone.php @@ -584,10 +584,17 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base { CRM_Core_Error::statusBounce(ts("Access denied"), CRM_Utils_System::url('civicrm')); } else { - CRM_Utils_System::redirect('/civicrm/login?anonAccessDenied'); - } + http_response_code(403); + + // render a login page + if (class_exists('CRM_Standaloneusers_Page_Login')) { + $loginPage = new CRM_Standaloneusers_Page_Login(); + $loginPage->assign('anonAccessDenied', TRUE); + return $loginPage->run(); + } - // TODO: Prettier error page + throw new CRM_Core_Exception('Access denied. Standaloneusers extension not found'); + } } } diff --git a/ext/standaloneusers/CRM/Standaloneusers/Page/Login.php b/ext/standaloneusers/CRM/Standaloneusers/Page/Login.php index d9017529dc..31aa791d6e 100644 --- a/ext/standaloneusers/CRM/Standaloneusers/Page/Login.php +++ b/ext/standaloneusers/CRM/Standaloneusers/Page/Login.php @@ -17,7 +17,6 @@ class CRM_Standaloneusers_Page_Login extends CRM_Core_Page { // Remove breadcrumb for login page. $this->assign('breadcrumb', NULL); - $this->assign('anonAccessDenied', isset($_GET['anonAccessDenied'])); $this->assign('justLoggedOut', isset($_GET['justLoggedOut'])); parent::run(); -- 2.25.1