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

Change password in endless loop

    XMLWordPrintable

    Details

      Description

      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

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            michael-milette Michael Milette
            Peer reviewer:
            Frédéric Massart
            Integrator:
            Dan Poltawski
            Tester:
            Nobody
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Barbara Ramiro, Bas Brands
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              9/Sep/13