From 102efecdcc465a18d5a79e5c2e7f4a2483bc5b9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de>
Date: Fri, 3 Jan 2025 09:39:24 +0000
Subject: [PATCH] =?UTF-8?q?Resolve=20#5029=20"=E2=80=9EError:=20Fehlende?=
 =?UTF-8?q?=20Session.=E2=80=9C=20beim=20Aufruf=20einer=20falschen=20Trail?=
 =?UTF-8?q?s=20URL"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5029

Merge request studip/studip!3800
---
 templates/header.php                  | 10 +++++-----
 templates/login/_header_languages.php |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/templates/header.php b/templates/header.php
index 64d1c3cd6f6..b4ced53f159 100644
--- a/templates/header.php
+++ b/templates/header.php
@@ -123,10 +123,10 @@ if ($navigation) {
                           && Navigation::getItem('/profile')->isActive();
                 ?>
 
-                
+
 
                 <? if (is_object($GLOBALS['perm']) && PersonalNotifications::isActivated() && $GLOBALS['perm']->have_perm('autor')) : ?>
-                
+
                     <? $notifications = PersonalNotifications::getMyNotifications() ?>
                     <? $lastvisit = (int)UserConfig::get($GLOBALS['user']->id)->getValue('NOTIFICATIONS_SEEN_LAST_DATE') ?>
                     <? foreach ($notifications as $notification) {
@@ -137,7 +137,7 @@ if ($navigation) {
                 <!-- User-Avatar -->
                 <li class="header_avatar_container <?= !empty($alert) ? 'alert' : '' ?> <? if ($active) echo 'active'; ?>" id="avatar-menu-container">
                     <div id="notification-container"  <?= count($notifications) > 0 ? ' class="hoverable"' : '' ?>>
-                        
+
                         <button id="notification_marker" data-toggles="#notification_checkbox" <?= !empty($alert) ? ' class="alert"' : "" ?>
                                 title="<?= sprintf(
                                     ngettext('%u Benachrichtigung', '%u Benachrichtigungen', count($notifications)),
@@ -212,7 +212,7 @@ if ($navigation) {
             <? else: ?>
                 <li>
                     <form method="post" action="<?= URLHelper::getLink(Request::url(), ['cancel_login' => null]) ?>">
-                        <?= CSRFProtection::tokenTag() ?>
+                        <? try {echo CSRFProtection::tokenTag();} catch (SessionRequiredException){}?>
                         <input type="hidden" name="user_config_submitted" value="1">
                         <div id="contrast">
                             <? if (!empty($_SESSION['contrast'])): ?>
@@ -222,7 +222,7 @@ if ($navigation) {
                             <? else: ?>
                                 <?= Icon::create('accessibility', Icon::ROLE_INFO_ALT)->asImg(24) ?>
                                 <button class="as-link" name="set_contrast"><?= _('Hohen Kontrast aktivieren') ?></button>
-                                <?= tooltipIcon(_('Aktiviert einen hohen Kontrast gemäß WCAG 2.1. Diese Einstellung wird nach dem Login übernommen. 
+                                <?= tooltipIcon(_('Aktiviert einen hohen Kontrast gemäß WCAG 2.1. Diese Einstellung wird nach dem Login übernommen.
                                 Sie können sie in Ihren persönlichen Einstellungen ändern.'), false, false, true); ?>
                             <? endif ?>
                         </div>
diff --git a/templates/login/_header_languages.php b/templates/login/_header_languages.php
index def8d322e90..db8f41a82de 100644
--- a/templates/login/_header_languages.php
+++ b/templates/login/_header_languages.php
@@ -1,5 +1,5 @@
 <form id="language-selector" method="POST" action="<?= URLHelper::getLink(Request::url(), ['cancel_login' => null]) ?>">
-    <?= CSRFProtection::tokenTag() ?>
+    <? try {echo CSRFProtection::tokenTag();} catch (SessionRequiredException){}?>
     <input type="hidden" name="user_config_submitted" value="1">
     <select id="languages" name="set_language" class="select2" onchange="this.form.submit()">
         <? foreach ($GLOBALS['INSTALLED_LANGUAGES'] as $temp_language_key => $temp_language): ?>
@@ -32,4 +32,4 @@
             templateSelection: format
         });
     });
-</script>
\ No newline at end of file
+</script>
-- 
GitLab