mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-79202' of https://github.com/paulholden/moodle
This commit is contained in:
commit
9d4dba81b7
@ -318,7 +318,7 @@ class external extends external_api {
|
||||
$timenow = time();
|
||||
if ($timenow - $last < $mintimereq) {
|
||||
$minutes = $mintimereq / MINSECS;
|
||||
throw new moodle_exception('autologinkeygenerationlockout', 'tool_mobile', $minutes);
|
||||
throw new moodle_exception('autologinkeygenerationlockout', 'tool_mobile', '', $minutes);
|
||||
}
|
||||
set_user_preference('tool_mobile_autologin_request_last', $timenow, $USER);
|
||||
|
||||
|
@ -414,18 +414,18 @@ class externallib_test extends externallib_advanced_testcase {
|
||||
$result = external::get_autologin_key($token->privatetoken);
|
||||
$result = external_api::clean_returnvalue(external::get_autologin_key_returns(), $result);
|
||||
|
||||
// Change min time between requests to 30 seconds.
|
||||
set_config('autologinmintimebetweenreq', 30, 'tool_mobile');
|
||||
// Change min time between requests to 3 minutes.
|
||||
set_config('autologinmintimebetweenreq', 3 * MINSECS, 'tool_mobile');
|
||||
|
||||
// Mock a previous request, 60 seconds ago.
|
||||
$mocktime = time() - MINSECS;
|
||||
// Mock a previous request, 4 minutes ago.
|
||||
$mocktime = time() - (4 * MINSECS);
|
||||
set_user_preference('tool_mobile_autologin_request_last', $mocktime, $USER);
|
||||
$result = external::get_autologin_key($token->privatetoken); // All good, we were expecint 30 seconds or more.
|
||||
$result = external::get_autologin_key($token->privatetoken);
|
||||
$result = external_api::clean_returnvalue(external::get_autologin_key_returns(), $result);
|
||||
|
||||
// We just requested one token, we must wait.
|
||||
$this->expectException('moodle_exception');
|
||||
$this->expectExceptionMessage(get_string('autologinkeygenerationlockout', 'tool_mobile'));
|
||||
$this->expectExceptionMessage(get_string('autologinkeygenerationlockout', 'tool_mobile', 3));
|
||||
$result = external::get_autologin_key($token->privatetoken);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user