From 9434b600c9b6c5c9b1264323caac1cafa81ce914 Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Tue, 27 Jun 2023 10:01:49 +0800 Subject: [PATCH] MDL-78578 enrol_lti: permit launch cache access during launch redirects This handles things like site policies, which store the current URL, redirect to the policy agreement, then redirect back the current URL afterwards. In such cases, we want to redirect back with 'launchid' set so that we can fetch the id_token from the session cache. This is the same thing we already do during account binding, so the patch only makes sure the PAGE->url is properly set before calling require_login. --- enrol/lti/launch.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/enrol/lti/launch.php b/enrol/lti/launch.php index 4c36ed01596..f5fc8554d27 100644 --- a/enrol/lti/launch.php +++ b/enrol/lti/launch.php @@ -108,10 +108,12 @@ $auth->complete_login( $legacyconsumersecrets ?? [] ); -require_login(null, false); global $USER, $CFG, $PAGE; +// Page URL must be set before the require_login check, so that things like policies can redirect back with the launchid. +$PAGE->set_url(new moodle_url('/enrol/lti/launch.php'), ['launchid' => $messagelaunch->getLaunchId()]); + +require_login(null, false); $PAGE->set_context(context_system::instance()); -$PAGE->set_url(new moodle_url('/enrol/lti/launch.php')); $PAGE->set_pagelayout('popup'); // Same layout as the tool.php page in Legacy 1.1/2.0 launches. $PAGE->set_title(get_string('opentool', 'enrol_lti'));