Moodle
  1. Moodle
  2. MDL-21018

Mnet - link to mnet_email.php shows when it shouldn't

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.7
    • Fix Version/s: 1.9.8, 2.0
    • Component/s: Authentication, MNet
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      when Mnet is enabled, if a user gets their password wrong on the login screen a link to Mnet_email is always shown even when SSO to Moodle isn't configured - if a site is only configured to allow their users to SSO to other sites - not the other way round, Moodle shouldn't show the link as it's useless - here's a patch that fixes it:

      — a/login/index.php
      +++ b/login/index.php
      @@ -238,7 +238,8 @@ httpsrequired();
      // TODO: if the user failed to authenticate, check if the username
      if ( !empty($CFG->mnet_dispatcher_mode)
      && $CFG->mnet_dispatcher_mode === 'strict'

      • && is_enabled_auth('mnet'))
        Unknown macro: {+ && is_enabled_auth('mnet') &&+ record_exists('mnet_host2service', 'publish', '1', 'serviceid', get_field('mnet_service', 'id', 'name', 'sso_sp')) ) { $errormsg .= get_string('loginlinkmnetuser', 'mnet', "mnet_email.php?u=$frm->username"); } }

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Dan Marsden added a comment -

            hmm... that patch only partially fixes it - when an Mnet Peer is deleted, it just flags them as deleted and doesn't remove the records - so we need to check for records that exist for hosts with deleted set to 0 - will try to create an improved patch sometime today.

            Show
            Dan Marsden added a comment - hmm... that patch only partially fixes it - when an Mnet Peer is deleted, it just flags them as deleted and doesn't remove the records - so we need to check for records that exist for hosts with deleted set to 0 - will try to create an improved patch sometime today.
            Hide
            Dan Marsden added a comment -

            here's a better one instead of the record_exists call

            record_exists_sql("SELECT h.id from {$CFG->prefix}mnet_host h
            INNER JOIN {$CFG->prefix}mnet_host2service m ON h.id=m.hostid
            INNER JOIN {$CFG->prefix}mnet_service s ON s.id=m.serviceid
            WHERE s.name='sso_sp' AND h.deleted=0 AND m.publish = 1;") ) {

            Show
            Dan Marsden added a comment - here's a better one instead of the record_exists call record_exists_sql("SELECT h.id from {$CFG->prefix}mnet_host h INNER JOIN {$CFG->prefix}mnet_host2service m ON h.id=m.hostid INNER JOIN {$CFG->prefix}mnet_service s ON s.id=m.serviceid WHERE s.name='sso_sp' AND h.deleted=0 AND m.publish = 1;") ) {
            Hide
            Dan Marsden added a comment -

            oops - bad copy paste - shouldn't have the semicolon at the end!
            record_exists_sql("SELECT h.id from {$CFG->prefix}mnet_host h
            INNER JOIN {$CFG->prefix}mnet_host2service m ON h.id=m.hostid
            INNER JOIN {$CFG->prefix}mnet_service s ON s.id=m.serviceid
            WHERE s.name='sso_sp' AND h.deleted=0 AND m.publish = 1") ) {

            Show
            Dan Marsden added a comment - oops - bad copy paste - shouldn't have the semicolon at the end! record_exists_sql("SELECT h.id from {$CFG->prefix}mnet_host h INNER JOIN {$CFG->prefix}mnet_host2service m ON h.id=m.hostid INNER JOIN {$CFG->prefix}mnet_service s ON s.id=m.serviceid WHERE s.name='sso_sp' AND h.deleted=0 AND m.publish = 1") ) {
            Hide
            Penny Leach added a comment -

            thanks, I committed that fix along with a username/host check to stable & head.

            Show
            Penny Leach added a comment - thanks, I committed that fix along with a username/host check to stable & head.
            Hide
            Dan Marsden added a comment -

            Thanks Penny, wanted someone else to review this - btw, isn't it testing Tuesday?

            Show
            Dan Marsden added a comment - Thanks Penny, wanted someone else to review this - btw, isn't it testing Tuesday?
            Hide
            Penny Leach added a comment -

            argh! I didn't get an email about it though! I forgot!

            Show
            Penny Leach added a comment - argh! I didn't get an email about it though! I forgot!

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: