MDL-40045 auth: removed unnecessary add_to_log calls
authorMark Nelson <markn@moodle.com>
Wed, 4 Sep 2013 10:05:25 +0000 (18:05 +0800)
committerMark Nelson <markn@moodle.com>
Mon, 21 Oct 2013 03:53:30 +0000 (11:53 +0800)
Both LDAP and Shibboleth call complete_user_login which triggers
a user_loggedin event that handles the legacy call to add_to_log.

auth/ldap/auth.php
auth/shibboleth/index.php
lib/classes/event/user_loggedin.php

index 0f80f7d..f92c08d 100644 (file)
@@ -1739,12 +1739,11 @@ class auth_plugin_ldap extends auth_plugin_base {
             return false;
         }
         $username   = $cf[$key];
+
         // Here we want to trigger the whole authentication machinery
         // to make sure no step is bypassed...
         $user = authenticate_user_login($username, $key);
         if ($user) {
-            add_to_log(SITEID, 'user', 'login', "view.php?id=$USER->id&course=".SITEID,
-                       $user->id, 0, $user->id);
             complete_user_login($user);
 
             // Cleanup the key to prevent reuse...
@@ -1763,7 +1762,10 @@ class auth_plugin_ldap extends auth_plugin_base {
                 $urltogo = $CFG->wwwroot.'/';
                 unset($SESSION->wantsurl);
             }
-            redirect($urltogo);
+            // We do not want to redirect if we are in a PHPUnit test.
+            if (!PHPUNIT_TEST) {
+                redirect($urltogo);
+            }
         }
         // Should never reach here.
         return false;
index 3eaf702..5256750 100644 (file)
 
         if ($shibbolethauth->user_login($frm->username, $frm->password)
                 && $user = authenticate_user_login($frm->username, $frm->password)) {
-
-            enrol_check_plugins($user);
-            \core\session\manager::set_user($user);
-
-            $USER->loggedin = true;
-            $USER->site     = $CFG->wwwroot; // for added security, store the site in the
-
-            update_user_login_times();
-
-            // Don't show previous shibboleth username on login page
-
-            set_login_session_preferences();
-
-            unset($SESSION->lang);
-            $SESSION->justloggedin = true;
-
-            add_to_log(SITEID, 'user', 'login', "view.php?id=$USER->id&course=".SITEID, $USER->id, 0, $USER->id);
+            complete_user_login($user);
 
             if (user_not_fully_set_up($USER)) {
                 $urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&amp;course='.SITEID;
index 9065aa7..9628e31 100644 (file)
@@ -50,7 +50,7 @@ class user_loggedin extends \core\event\base {
      * @return array
      */
     protected function get_legacy_logdata() {
-        return array(SITEID, 'user', 'login', "view.php?id=" . $this->data['objectid'] . "&course=".SITEID,
+        return array(SITEID, 'user', 'login', 'view.php?id=' . $this->data['objectid'] . '&course=' . SITEID,
             $this->data['objectid'], 0, $this->data['objectid']);
     }