From c12bfcefdd6713733e7bf282020bcf0c4370b20b Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Tue, 24 Oct 2017 13:24:50 +0200 Subject: [PATCH] MDL-60572 admin: Fix forgottenpasswordurl for WS We should expect URLs in that field. The tool_mobile change is to not break the WS response if forgottenpasswordurl does not contain a URL. --- admin/tool/mobile/classes/api.php | 2 +- admin/tool/mobile/tests/externallib_test.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/tool/mobile/classes/api.php b/admin/tool/mobile/classes/api.php index 3c247e3e052..b5f76bbb492 100644 --- a/admin/tool/mobile/classes/api.php +++ b/admin/tool/mobile/classes/api.php @@ -128,7 +128,7 @@ class api { 'rememberusername' => $CFG->rememberusername, 'authloginviaemail' => $CFG->authloginviaemail, 'registerauth' => $CFG->registerauth, - 'forgottenpasswordurl' => $CFG->forgottenpasswordurl, + 'forgottenpasswordurl' => clean_param($CFG->forgottenpasswordurl, PARAM_URL), // We may expect a mailto: here. 'authinstructions' => $authinstructions, 'authnoneenabled' => (int) is_enabled_auth('none'), 'enablewebservices' => $CFG->enablewebservices, diff --git a/admin/tool/mobile/tests/externallib_test.php b/admin/tool/mobile/tests/externallib_test.php index 126ea1c8b1c..8519464964a 100644 --- a/admin/tool/mobile/tests/externallib_test.php +++ b/admin/tool/mobile/tests/externallib_test.php @@ -97,11 +97,13 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase { set_config('typeoflogin', api::LOGIN_VIA_BROWSER, 'tool_mobile'); set_config('logo', 'mock.png', 'core_admin'); set_config('logocompact', 'mock.png', 'core_admin'); + set_config('forgottenpasswordurl', 'mailto:fake@email.zy'); // Test old hack. list($authinstructions, $notusedformat) = external_format_text($authinstructions, FORMAT_MOODLE, $context->id); $expected['registerauth'] = 'email'; $expected['authinstructions'] = $authinstructions; $expected['typeoflogin'] = api::LOGIN_VIA_BROWSER; + $expected['forgottenpasswordurl'] = ''; // Expect empty when it's not an URL. if ($logourl = $OUTPUT->get_logo_url()) { $expected['logourl'] = $logourl->out(false);