From 3f455264b9a89b3122feedd31aa7b26f6d61ef24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de>
Date: Mon, 6 Jan 2025 16:17:22 +0000
Subject: [PATCH] Resolve #5098 "course/lti-Controller: Exception beim Aufruf"

Closes #5098

Merge request studip/studip!3811
---
 app/controllers/course/lti.php | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/app/controllers/course/lti.php b/app/controllers/course/lti.php
index 4db777661b5..ab403af6f50 100644
--- a/app/controllers/course/lti.php
+++ b/app/controllers/course/lti.php
@@ -18,21 +18,26 @@ class Course_LtiController extends StudipController
 {
     use NegotiatesWithPsr7;
 
+    public function __construct(\Trails\Dispatcher $dispatcher)
+    {
+        // these actions do not require session authentication
+        $action = basename(get_route());
+        if (!in_array($action, ['profile', 'outcome'])) {
+            $this->with_session = true;
+            $this->allow_nobody = false;
+        }
+        parent::__construct($dispatcher);
+    }
     /**
      * Callback function being called before an action is executed.
      */
     public function before_filter(&$action, &$args)
     {
+        parent::before_filter($action, $args);
         // these actions do not require session authentication
         if (in_array($action, ['profile', 'outcome'])) {
-            return parent::before_filter($action, $args);
+            return;
         }
-
-        $this->with_session = true;
-        $this->allow_nobody = false;
-
-        parent::before_filter($action, $args);
-
         $this->course_id = Context::getId();
         $this->edit_perm = $GLOBALS['perm']->have_studip_perm('tutor', $this->course_id);
 
-- 
GitLab