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

Default home page for users "user preference" ignored when $CFG->forcelogin is true

XMLWordPrintable

    • MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • wip-MDL-37983-master
    • Hide

      Notice

      • For this test you will need to make alterations to the database.

      Testing

      1. Log in as an admin.
      2. Set defaulthomepage to 'User preference' (Settings ► Site administration ► Appearance ► Navigation)
      3. Login as any user type e.g. 'student' and in the navigation browse to 'Home'.
      4. In settings expand My profile settings and check that there is a `Make this my default home page` link. (If not then go to My Home and check the same settings there).
      5. Do not Click this link. We want to leave the default home page to 'My Home'.
      6. Browse to any course.
        • Check that 'My home' is the first item in the navbar and that it links to /my/.
      7. Logout and then log back in.
        • Check that when logged in that you are redirected to 'My Home'.
      8. As the admin, go to [Settings ► Site administration ► Security ► Site policies] and set 'Force users to login' to yes (checked).
      9. As the student log out and log back in.
        • Check that when logged in that you are redirected to 'My Home'.
      10. Go into the database and alter the user fields. Remove the 'must be null' from the lastname field. Then delete the last name of the student that you are using to log in and out with.
      11. As the student, log out and log back in.
        • Check that you are redirected to the student edit page.
      12. Copy a url to redirect to such as http://your.moodle.site/course/view.php?id=3.
      13. As the student log out and then try to go straight to the above url.
        • Check that the student is redirected to the url location after logging in.
      14. The above steps should be re-done with the site page as the default home page.
      Show
      Notice For this test you will need to make alterations to the database. Testing Log in as an admin. Set defaulthomepage to 'User preference' (Settings ► Site administration ► Appearance ► Navigation) Login as any user type e.g. 'student' and in the navigation browse to 'Home'. In settings expand My profile settings and check that there is a `Make this my default home page` link. (If not then go to My Home and check the same settings there). Do not Click this link. We want to leave the default home page to 'My Home'. Browse to any course. Check that 'My home' is the first item in the navbar and that it links to /my/. Logout and then log back in. Check that when logged in that you are redirected to 'My Home'. As the admin, go to [Settings ► Site administration ► Security ► Site policies] and set 'Force users to login' to yes (checked). As the student log out and log back in. Check that when logged in that you are redirected to 'My Home'. Go into the database and alter the user fields. Remove the 'must be null' from the lastname field. Then delete the last name of the student that you are using to log in and out with. As the student, log out and log back in. Check that you are redirected to the student edit page. Copy a url to redirect to such as http://your.moodle.site/course/view.php?id=3 . As the student log out and then try to go straight to the above url. Check that the student is redirected to the url location after logging in. The above steps should be re-done with the site page as the default home page.

      Default home page 'user preference' has no effect on the first page displayed after logging in. The site home is always displayed regardless of which page a user has set as their default homepage.

      MDL-32108 was supposed to fix this, but it hasn't.

      This comment suggests the stanza be moved into the "else" clause above it. As a result, a fix that was working is now broken, and all users are sent to site home.

      If $SESSION->wantsurl === $CFG->wwwroot . '/' you end up in the "elseif" clause:

      } else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0 or strpos($SESSION->wantsurl, str_replace('http://', 'https://', $CFG->wwwroot)) === 0)) {
          $urltogo = $SESSION->wantsurl;    /// Because it's an address in this site
          unset($SESSION->wantsurl);
      

      because strpos($SESSION->wantsurl, $CFG->wwwroot) === 0 in that case. Something earlier in the sequence is setting $SESSION->wantsurl, possibly require_login() in moodlelib.php because we force login at our site.

      I think there are two possible fixes. Either detect the fact that $SESSION->wantsurl === $CFG->wwwroot . '/' in the "elseif" clause above, or move the whole homepage detecting code outside the if .. elseif .. else and place it in its own clause as below:

      if ($urltogo === $CFG->wwwroot.'/') {
          $home_page = get_home_page();
          // Go to my-moodle page instead of site homepage if defaulthomepage set to homepage_my
          if ($home_page == HOMEPAGE_MY && !is_siteadmin() && !isguestuser()) {
              if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') {
                  $urltogo = $CFG->wwwroot.'/my/';
              }
          }
      }
      

            abgreeve Adrian Greeve
            chrisf Chris Fryer
            Sam Hemelryk Sam Hemelryk
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Frédéric Massart Frédéric Massart
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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