Skip to content

Commit f1e0303

Browse files
Copilotskerbis
andauthored
fix(debug): Restrict debug sidebar to backend users only (#433)
* Initial plan * fix(debug): Restrict debug sidebar to backend users only Co-authored-by: skerbis <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: skerbis <[email protected]>
1 parent 8c6e68f commit f1e0303

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

fragments/ConsentManager/box_cssjs.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,29 @@
5050
$googleConsentModeScriptUrl = $addon->getAssetsUrl($googleConsentModeScriptFile);
5151
$googleConsentModeOutput .= ' <script src="' . $googleConsentModeScriptUrl . '" defer></script>' . PHP_EOL;
5252

53-
// Debug-Script laden wenn Debug-Modus aktiviert
53+
// Debug-Script laden wenn Debug-Modus aktiviert UND User im Backend eingeloggt
5454
if (isset($consent_manager->domainInfo['google_consent_mode_debug'])
5555
&& 1 === $consent_manager->domainInfo['google_consent_mode_debug']) {
56-
$debugScriptUrl = $addon->getAssetsUrl('consent_debug.js');
57-
$googleConsentModeOutput .= ' <script src="' . $debugScriptUrl . '" defer></script>' . PHP_EOL;
58-
59-
// Debug-Konfiguration für JavaScript verfügbar machen
60-
$googleConsentModeOutput .= ' <script>' . PHP_EOL;
61-
$googleConsentModeOutput .= ' window.consentManagerDebugConfig = ' . json_encode([
62-
'mode' => $consent_manager->domainInfo['google_consent_mode_enabled'],
63-
'auto_mapping' => $consent_manager->domainInfo['google_consent_mode_enabled'] === 'auto',
64-
'debug_enabled' => true,
65-
'domain' => rex_request::server('HTTP_HOST'),
66-
'cache_log_id' => $consent_manager->cacheLogId,
67-
'version' => $consent_manager->version,
68-
]) . ';' . PHP_EOL;
69-
$googleConsentModeOutput .= ' </script>' . PHP_EOL;
56+
// User für Frontend initialisieren
57+
rex_backend_login::createUser();
58+
59+
// Nur für eingeloggte Backend-Benutzer
60+
if (rex_backend_login::hasSession() && null !== rex::getUser()) {
61+
$debugScriptUrl = $addon->getAssetsUrl('consent_debug.js');
62+
$googleConsentModeOutput .= ' <script src="' . $debugScriptUrl . '" defer></script>' . PHP_EOL;
63+
64+
// Debug-Konfiguration für JavaScript verfügbar machen
65+
$googleConsentModeOutput .= ' <script>' . PHP_EOL;
66+
$googleConsentModeOutput .= ' window.consentManagerDebugConfig = ' . json_encode([
67+
'mode' => $consent_manager->domainInfo['google_consent_mode_enabled'],
68+
'auto_mapping' => $consent_manager->domainInfo['google_consent_mode_enabled'] === 'auto',
69+
'debug_enabled' => true,
70+
'domain' => rex_request::server('HTTP_HOST'),
71+
'cache_log_id' => $consent_manager->cacheLogId,
72+
'version' => $consent_manager->version,
73+
]) . ';' . PHP_EOL;
74+
$googleConsentModeOutput .= ' </script>' . PHP_EOL;
75+
}
7076
}
7177

7278
// Auto-Mapping wird jetzt im Frontend-JS gehandhabt

0 commit comments

Comments
 (0)