standalone access denied: show login form with 403 on page route
authorbenjamin <benjamin>
Thu, 7 Dec 2023 17:17:07 +0000 (17:17 +0000)
committerbenjamin <benjamin>
Thu, 7 Dec 2023 22:19:41 +0000 (22:19 +0000)
CRM/Utils/System/Standalone.php
ext/standaloneusers/CRM/Standaloneusers/Page/Login.php

index 18f5b7bfc7e6933dd94d9c50d4802b09ff01f80e..265d2ef4385ebd5f75e618276f29faa2b85e7835 100644 (file)
@@ -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');
+    }
   }
 
 }
index d9017529dc5bd94e0ea85a790a6c3665cb7be045..31aa791d6ea318bb107d14cdb7a5b5850c9ab47d 100644 (file)
@@ -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();