mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-72173 behat: Respect login page preference
This commit is contained in:
parent
92018f6971
commit
11ebfe601c
1 changed files with 7 additions and 3 deletions
|
@ -26,6 +26,7 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
require(__DIR__.'/../../../config.php');
|
require(__DIR__.'/../../../config.php');
|
||||||
|
require_once("{$CFG->dirroot}/login/lib.php");
|
||||||
|
|
||||||
$behatrunning = defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING;
|
$behatrunning = defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING;
|
||||||
if (!$behatrunning) {
|
if (!$behatrunning) {
|
||||||
|
@ -33,14 +34,14 @@ if (!$behatrunning) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$username = required_param('username', PARAM_ALPHANUMEXT);
|
$username = required_param('username', PARAM_ALPHANUMEXT);
|
||||||
$wantsurl = new moodle_url(optional_param('wantsurl', '/', PARAM_URL));
|
$wantsurl = optional_param('wantsurl', null, PARAM_URL);
|
||||||
|
|
||||||
if (isloggedin()) {
|
if (isloggedin()) {
|
||||||
// If the user is already logged in, log them out and redirect them back to login again.
|
// If the user is already logged in, log them out and redirect them back to login again.
|
||||||
require_logout();
|
require_logout();
|
||||||
redirect(new moodle_url('/auth/tests/behat/login.php', [
|
redirect(new moodle_url('/auth/tests/behat/login.php', [
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'wantsurl' => $wantsurl->out(false),
|
'wantsurl' => (new moodle_url($wantsurl))->out(false),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,4 +83,7 @@ if (!complete_user_login($user)) {
|
||||||
throw new Exception("Failed to login as behat step for $username");
|
throw new Exception("Failed to login as behat step for $username");
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect($wantsurl);
|
if (empty($wantsurl)) {
|
||||||
|
$wantsurl = core_login_get_return_url();
|
||||||
|
}
|
||||||
|
redirect(new moodle_url($wantsurl));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue