Permalink
Browse files

MDL-29678 lib: Require login now overrides to false for AJAX scripts

  • Loading branch information...
1 parent a897a25 commit 8491ee245ba333c50208dd5cb3d8dab156fc9445 Sam Hemelryk committed Mar 26, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/moodlelib.php
View
@@ -2369,6 +2369,13 @@ function require_login($courseorid = NULL, $autologinguest = true, $cm = NULL, $
}
}
+ // If this is an AJAX request and $setwantsurltome is true then we need to override it and set it to false.
+ // Otherwise the AJAX request URL will be set to $SESSION->wantsurl and events such as self enrolment in the future
+ // risk leading the user back to the AJAX request URL.
+ if ($setwantsurltome && defined('AJAX_SCRIPT') && AJAX_SCRIPT) {
+ $setwantsurltome = false;
+ }
+
// If the user is not even logged in yet then make sure they are
if (!isloggedin()) {
if ($autologinguest and !empty($CFG->guestloginbutton) and !empty($CFG->autologinguests)) {

0 comments on commit 8491ee2

Please sign in to comment.