Fix issue with keylifetime being string

This commit is contained in:
Dmitrii Metelkin 2016-08-18 14:44:21 +10:00
parent 29d61cad41
commit 3e8c4138f0
2 changed files with 2 additions and 2 deletions

View file

@ -93,7 +93,7 @@ class core_userkey_manager implements userkey_manager_interface {
$this->iprestriction = getremoteaddr(null);
}
if (isset($config->keylifetime) && is_int($config->keylifetime)) {
if (isset($config->keylifetime) && (int)$config->keylifetime > 0) {
$this->validuntil = time() + $config->keylifetime;
} else {
$this->validuntil = time() + self::DEFAULT_KEY_LIFE_TIME_IN_SECONDS;

View file

@ -258,7 +258,7 @@ class core_userkey_manager_testcase extends advanced_testcase {
$expectedscript = 'auth/userkey';
$expectedinstance = $this->user->id;
$expectediprestriction = null;
$expectedvaliduntil = time() + 60;
$expectedvaliduntil = time() + 3000;
$this->assertEquals($expectedvalue, $actualkey->value);
$this->assertEquals($expecteduserid, $actualkey->userid);