mirror of
https://github.com/moodle/moodle.git
synced 2025-03-11 03:15:24 +01:00
MDL-80835 enrol_lti: add cookies required notice to auth login endpoint
This will be displayed if the cookie checks fail, which currently occurs in Safari only.
This commit is contained in:
parent
b293cb5da6
commit
aea624fcb0
@ -263,4 +263,19 @@ class renderer extends plugin_renderer_base {
|
||||
return parent::render_from_template('enrol_lti/local/ltiadvantage/registration_view',
|
||||
$tcontext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a warning, indicating to the user that cookies are require but couldn't be set.
|
||||
*
|
||||
* @return string the html.
|
||||
*/
|
||||
public function render_cookies_required_notice(): string {
|
||||
$notification = new notification(get_string('cookiesarerequiredinfo', 'enrol_lti'), notification::NOTIFY_WARNING, false);
|
||||
$tcontext = [
|
||||
'heading' => get_string('cookiesarerequired', 'enrol_lti'),
|
||||
'notification' => $notification->export_for_template($this),
|
||||
];
|
||||
|
||||
return parent::render_from_template('enrol_lti/local/ltiadvantage/cookies_required_notice', $tcontext);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,10 @@ $string['addtocourse'] = 'Add to course';
|
||||
$string['addtogradebook'] = 'Add to gradebook';
|
||||
$string['allowframeembedding'] = 'Note: It is recommended that the site administration setting \'Allow frame embedding\' is enabled, so that tools are displayed within a frame rather than in a new window.';
|
||||
$string['authltimustbeenabled'] = 'Note: This plugin requires the LTI authentication plugin to be enabled too.';
|
||||
$string['cookiesarerequired'] = 'Cookies are blocked by your browser';
|
||||
$string['cookiesarerequiredinfo'] = 'This tool can\'t be launched because your browser seems to be blocking third-party cookies.
|
||||
<br><br>
|
||||
To use this tool, try changing your browser cookie settings or using a different browser.';
|
||||
$string['copiedtoclipboard'] = '{$a} copied to clipboard';
|
||||
$string['copytoclipboard'] = 'Copy to clipboard';
|
||||
$string['couldnotestablishproxy'] = 'Could not establish proxy with consumer.';
|
||||
|
@ -88,6 +88,17 @@ if (!isloggedin()) {
|
||||
'lti_message_hint' => $ltimessagehint,
|
||||
'client_id' => $_REQUEST['client_id'],
|
||||
]));
|
||||
if (!cookie_helper::cookies_supported()) {
|
||||
global $OUTPUT, $PAGE;
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_url(new moodle_url('/enrol/lti/login.php'));
|
||||
$PAGE->set_pagelayout('popup');
|
||||
echo $OUTPUT->header();
|
||||
$renderer = $PAGE->get_renderer('enrol_lti');
|
||||
echo $renderer->render_cookies_required_notice();
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// Now, do the OIDC login.
|
||||
|
@ -0,0 +1,50 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template enrol_lti/local/ltiadvantage/cookies_required_notice
|
||||
|
||||
Displays a notice, reporting that cookies are required but couldn't be set.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* heading
|
||||
* notification
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"heading": "Cookies are required",
|
||||
"notification": {
|
||||
"message": "You appear to be using an unsupported browser...",
|
||||
"extraclasses": "",
|
||||
"announce": true,
|
||||
"closebutton": false,
|
||||
"issuccess": false,
|
||||
"isinfo": false,
|
||||
"iswarning": true,
|
||||
"iserror": false
|
||||
}
|
||||
}
|
||||
}}
|
||||
<h3>{{heading}}</h3>
|
||||
{{#notification}}
|
||||
{{> core/notification}}
|
||||
{{/notification}}
|
Loading…
x
Reference in New Issue
Block a user