mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-56739 auth: Support launching the app upon user confirm
This commit is contained in:
parent
b0f00b3166
commit
b5f3e90e1c
2 changed files with 34 additions and 6 deletions
|
@ -31,6 +31,7 @@ require_once($CFG->libdir . '/externallib.php');
|
|||
$serviceshortname = required_param('service', PARAM_ALPHANUMEXT);
|
||||
$passport = required_param('passport', PARAM_RAW); // Passport send from the app to validate the response URL.
|
||||
$urlscheme = optional_param('urlscheme', 'moodlemobile', PARAM_NOTAGS); // The URL scheme the app supports.
|
||||
$confirmed = optional_param('confirmed', false, PARAM_BOOL); // If we are being redirected after user confirmation.
|
||||
|
||||
// Check web services enabled.
|
||||
if (!$CFG->enablewebservices) {
|
||||
|
@ -39,7 +40,8 @@ if (!$CFG->enablewebservices) {
|
|||
|
||||
// Check if the plugin is properly configured.
|
||||
$typeoflogin = get_config('tool_mobile', 'typeoflogin');
|
||||
if ($typeoflogin != tool_mobile\api::LOGIN_VIA_BROWSER and
|
||||
if (empty($SESSION->justloggedin) and
|
||||
$typeoflogin != tool_mobile\api::LOGIN_VIA_BROWSER and
|
||||
$typeoflogin != tool_mobile\api::LOGIN_VIA_EMBEDDED_BROWSER) {
|
||||
throw new moodle_exception('pluginnotenabledorconfigured', 'tool_mobile');
|
||||
}
|
||||
|
@ -87,11 +89,24 @@ if (!empty($forcedurlscheme)) {
|
|||
$location = "$urlscheme://token=$apptoken";
|
||||
|
||||
// For iOS 10 onwards, we have to simulate a user click.
|
||||
if (core_useragent::is_ios()) {
|
||||
$PAGE->set_context(null);
|
||||
// If we come from the confirmation page, we should display a nicer page.
|
||||
$isios = core_useragent::is_ios();
|
||||
if ($confirmed or $isios) {
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
$PAGE->set_url('/local/mobile/launch.php', array('service' => $serviceshortname, 'passport' => $passport, 'urlscheme' => $urlscheme));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($confirmed) {
|
||||
$confirmedstr = get_string('confirmed');
|
||||
$PAGE->navbar->add($confirmedstr);
|
||||
$PAGE->set_title($confirmedstr);
|
||||
echo $OUTPUT->notification($confirmedstr, \core\output\notification::NOTIFY_SUCCESS);
|
||||
echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter');
|
||||
echo $OUTPUT->single_button(new moodle_url('/course/'), get_string('courses'));
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
$notice = get_string('clickheretolaunchtheapp', 'tool_mobile');
|
||||
echo html_writer::link($location, $notice, array('id' => 'launchapp'));
|
||||
echo html_writer::script(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue