MDL-61622 auth: Return age verification settings in get_public_config

This commit is contained in:
Juan Leyva 2018-03-09 13:46:56 +01:00
parent 1f7565c121
commit 8d9dc60b43
3 changed files with 21 additions and 0 deletions

View File

@ -149,6 +149,8 @@ class api {
'maintenancemessage' => $maintenancemessage,
'mobilecssurl' => !empty($CFG->mobilecssurl) ? $CFG->mobilecssurl : '',
'tool_mobile_disabledfeatures' => get_config('tool_mobile', 'disabledfeatures'),
'country' => clean_param($CFG->country, PARAM_NOTAGS),
'agedigitalconsentverification' => \core_auth\digital_consent::is_age_digital_consent_verification_enabled(),
);
$typeoflogin = get_config('tool_mobile', 'typeoflogin');
@ -180,6 +182,12 @@ class api {
$settings['identityproviders'] = $identityprovidersdata;
}
// If age is verified, return also the admin contact details.
if ($settings['agedigitalconsentverification']) {
$settings['supportname'] = clean_param($CFG->supportname, PARAM_NOTAGS);
$settings['supportemail'] = clean_param($CFG->supportemail, PARAM_EMAIL);
}
return $settings;
}

View File

@ -161,6 +161,13 @@ class external extends external_api {
),
'Identity providers', VALUE_OPTIONAL
),
'country' => new external_value(PARAM_NOTAGS, 'Default site country', VALUE_OPTIONAL),
'agedigitalconsentverification' => new external_value(PARAM_BOOL, 'Whether age digital consent verification
is enabled.', VALUE_OPTIONAL),
'supportname' => new external_value(PARAM_NOTAGS, 'Site support contact name
(only if age verification is enabled).', VALUE_OPTIONAL),
'supportemail' => new external_value(PARAM_EMAIL, 'Site support contact email
(only if age verification is enabled).', VALUE_OPTIONAL),
'warnings' => new external_warnings(),
)
);

View File

@ -86,6 +86,8 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
'mobilecssurl' => '',
'tool_mobile_disabledfeatures' => '',
'launchurl' => "$CFG->wwwroot/$CFG->admin/tool/mobile/launch.php",
'country' => $CFG->country,
'agedigitalconsentverification' => \core_auth\digital_consent::is_age_digital_consent_verification_enabled(),
'warnings' => array()
);
$this->assertEquals($expected, $result);
@ -98,12 +100,16 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
set_config('logo', 'mock.png', 'core_admin');
set_config('logocompact', 'mock.png', 'core_admin');
set_config('forgottenpasswordurl', 'mailto:fake@email.zy'); // Test old hack.
set_config('agedigitalconsentverification', 1);
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.
$expected['agedigitalconsentverification'] = true;
$expected['supportname'] = $CFG->supportname;
$expected['supportemail'] = $CFG->supportemail;
if ($logourl = $OUTPUT->get_logo_url()) {
$expected['logourl'] = $logourl->out(false);