Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-41255

Change password in endless loop

XMLWordPrintable

      SUMMARY

      I am using a password expiry plugin. When I am prompted to change my password, the change password form goes into an endless loop, going back and forth between the confirmation form with the continue button and the change password screen.

      One might immediately jump to the conclusion that this is a plugin issue however, as you will see below, it's actually a result of a coding error in the core Moodle code.

      DESIRED BEHAVIOUR

      After successfully changing my password and clicking continue, I should be sent to the profile screen as the normal change password process does.

      SUGGESTED SOLUTION

      Fix line 43 of /login/change_password.php as follows:

      Replace:

      or stripos(str_replace('https://', 'http://', $SESSION->wantsurl), str_replace('https://', 'http://', $CFG->wwwroot.'/login/change_password.php') === 0)) {

      With:

      or stripos(str_replace('https://', 'http://', $SESSION->wantsurl), str_replace('https://', 'http://', $CFG->wwwroot.'/login/change_password.php')) === 0) {

      The difference is very subtle. There is are two closing )) after the ===0)), one of which needs to be moved before the ) === 0) because the comparison is supposed to apply to the results of the stripos() function and not to the results of the str_replace() function which doesn't make sense.

      The resulting code block should look like this:

      if (empty($SESSION->wantsurl)
      or stripos(str_replace('https://', 'http://', $SESSION->wantsurl), str_replace('https://', 'http://', $CFG->wwwroot.'/login/change_password.php')) === 0)

      { $returnto = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$id"; }

      else

      { $returnto = $SESSION->wantsurl; }

      I would appreciate it very much if you could help me get this fix integrated into future versions of Moodle.

      Best regards,

      Michael

            skodak Petr Skoda
            michael-milette Michael Milette
            Frédéric Massart Frédéric Massart
            Dan Poltawski Dan Poltawski
            Nobody Nobody
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.