Merge pull request #3 from CatalystIT-AU/issue#1
Fix #1 when redirecting to server root, not a moodle root
This commit is contained in:
commit
5c5b003f5c
2 changed files with 5 additions and 6 deletions
6
auth.php
6
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue