diff --git a/classes/core_userkey_manager.php b/classes/core_userkey_manager.php index 8d66cd9..62b0714 100644 --- a/classes/core_userkey_manager.php +++ b/classes/core_userkey_manager.php @@ -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; diff --git a/tests/core_userkey_manager_test.php b/tests/core_userkey_manager_test.php index 3e62f22..6cc2c18 100644 --- a/tests/core_userkey_manager_test.php +++ b/tests/core_userkey_manager_test.php @@ -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);