MDL-40045 auth: removed unnecessary add_to_log calls

Both LDAP and Shibboleth call complete_user_login which triggers
a user_loggedin event that handles the legacy call to add_to_log.
This commit is contained in:
Mark Nelson 2013-09-04 18:05:25 +08:00
parent 4e47920f08
commit 5991cabfd7
3 changed files with 7 additions and 21 deletions

View 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;

View File

@ -46,23 +46,7 @@
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.'&course='.SITEID;

View 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']);
}