Skip to content

Commit

Permalink
MDL-78801 tool_mobile: Auto logout settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Jul 28, 2023
1 parent b4cd637 commit 81b4677
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions admin/tool/mobile/classes/api.php
Expand Up @@ -65,6 +65,12 @@ class api {
const DEFAULT_ANDROID_APP_ID = 'com.moodle.moodlemobile';
/** @var string Default iOS app id */
const DEFAULT_IOS_APP_ID = '633359593';
/** @var int AUTOLOGOUT disabled value */
const AUTOLOGOUT_DISABLED = 0;
/** @var int AUTOLOGOUT type inmediate value */
const AUTOLOGOUT_INMEDIATE = 1;
/** @var int AUTOLOGOUT type custom value */
const AUTOLOGOUT_CUSTOM = 2;

/**
* Returns a list of Moodle plugins supporting the mobile app.
Expand Down Expand Up @@ -315,6 +321,8 @@ public static function get_config($section) {
$mintimereq = get_config('tool_mobile', 'autologinmintimebetweenreq');
$mintimereq = empty($mintimereq) ? 6 * MINSECS : $mintimereq;
$settings->tool_mobile_autologinmintimebetweenreq = $mintimereq;
$settings->tool_mobile_autologout = get_config('tool_mobile', 'autologout');
$settings->tool_mobile_autologouttime = get_config('tool_mobile', 'autologouttime');
}

if (empty($section) or $section == 'calendar') {
Expand Down
4 changes: 4 additions & 0 deletions admin/tool/mobile/lang/en/tool_mobile.php
Expand Up @@ -32,6 +32,10 @@
$string['autologinmintimebetweenreq'] = 'Minimum time between auto-login requests';
$string['autologinmintimebetweenreq_desc'] = 'The minimum time between auto-login requests from the mobile app. If app users are frequently asked to enter their credentials when viewing content embedded from the site, then set a lower value.';
$string['autologinnotallowedtoadmins'] = 'Auto-login is not allowed for site admins.';
$string['autologout'] = 'Enforce auto logout for your users';
$string['autologout_desc'] = 'For security reasons, you can enforce automatic logout for your users when they leave or close the app, or it goes to background. Users will have to log in again when they return to the app.';
$string['autologoutcustom'] = 'Custom time after users leave or close the app';
$string['autologoutinmediate'] = 'Immediately after users leave or close the app';
$string['cachedef_plugininfo'] = 'This stores the list of plugins with mobile addons';
$string['cachedef_subscriptiondata'] = 'This stores the Moodle app subscription information.';
$string['clickheretolaunchtheapp'] = 'Click here if the app does not open automatically.';
Expand Down
12 changes: 12 additions & 0 deletions admin/tool/mobile/settings.php
Expand Up @@ -102,6 +102,18 @@
new lang_string('typeoflogin', 'tool_mobile'),
new lang_string('typeoflogin_desc', 'tool_mobile'), 1, $options));

$options = [
tool_mobile\api::AUTOLOGOUT_DISABLED => new lang_string('never'),
tool_mobile\api::AUTOLOGOUT_INMEDIATE => new lang_string('autologoutinmediate', 'tool_mobile'),
tool_mobile\api::AUTOLOGOUT_CUSTOM => new lang_string('autologoutcustom', 'tool_mobile'),
];
$temp->add(new admin_setting_configselect('tool_mobile/autologout',
new lang_string('autologout', 'tool_mobile'),
new lang_string('autologout_desc', 'tool_mobile'), 0, $options));

$temp->add(new admin_setting_configduration('tool_mobile/autologouttime', '', '', DAYSECS));
$temp->hide_if('tool_mobile/autologouttime', 'tool_mobile/autologout', 'neq', tool_mobile\api::AUTOLOGOUT_CUSTOM);

$options = [
tool_mobile\api::QR_CODE_DISABLED => new lang_string('qrcodedisabled', 'tool_mobile'),
tool_mobile\api::QR_CODE_URL => new lang_string('qrcodetypeurl', 'tool_mobile'),
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/mobile/tests/externallib_test.php
Expand Up @@ -230,6 +230,8 @@ public function test_get_config(): void {
array('name' => 'tool_mobile_custommenuitems', 'value' => ''),
array('name' => 'tool_mobile_apppolicy', 'value' => ''),
array('name' => 'tool_mobile_autologinmintimebetweenreq', 'value' => 6 * MINSECS),
array('name' => 'tool_mobile_autologout', 'value' => get_config('tool_mobile', 'autologout')),
array('name' => 'tool_mobile_autologouttime', 'value' => get_config('tool_mobile', 'autologouttime')),
array('name' => 'calendartype', 'value' => $CFG->calendartype),
array('name' => 'calendar_site_timeformat', 'value' => $CFG->calendar_site_timeformat),
array('name' => 'calendar_startwday', 'value' => $CFG->calendar_startwday),
Expand Down

0 comments on commit 81b4677

Please sign in to comment.