diff --git a/auth.php b/auth.php index 09fcca0..6a24974 100644 --- a/auth.php +++ b/auth.php @@ -83,12 +83,12 @@ class auth_plugin_userkey extends auth_plugin_base { /** * Login user using userkey and return URL to redirect after. * - * @return mixed|string URL to redirect. + * @return string URL to redirect. * * @throws \moodle_exception If something went wrong. */ public function user_login_userkey() { - global $DB, $SESSION; + global $DB, $SESSION, $CFG; $keyvalue = required_param('key', PARAM_ALPHANUM); $wantsurl = optional_param('wantsurl', '', PARAM_URL); @@ -133,7 +133,7 @@ class auth_plugin_userkey extends auth_plugin_base { if (!empty($wantsurl)) { return $wantsurl; } else { - return '/'; + return $CFG->wwwroot; } } diff --git a/tests/auth_plugin_test.php b/tests/auth_plugin_test.php index 6335066..e71b42e 100644 --- a/tests/auth_plugin_test.php +++ b/tests/auth_plugin_test.php @@ -635,7 +635,7 @@ class auth_plugin_userkey_testcase extends advanced_testcase { * Test that a user loggs in correctly. */ public function test_that_user_logged_in() { - global $DB, $USER, $SESSION; + global $DB, $USER, $SESSION, $CFG; $key = new stdClass(); $key->value = 'UserLogin'; @@ -651,8 +651,7 @@ class auth_plugin_userkey_testcase extends advanced_testcase { // Using @ is the only way to test this. Thanks moodle! $redirect = @$this->auth->user_login_userkey(); - - $this->assertEquals('/', $redirect); + $this->assertEquals($CFG->wwwroot, $redirect); $this->assertEquals($this->user->id, $USER->id); $this->assertSame(sesskey(), $USER->sesskey); $this->assertObjectHasAttribute('userkey', $SESSION);